Re: [Haskell-cafe] A Monad for on-demand file generation?

2008-06-30 Thread Luke Palmer
2008/6/30 Joachim Breitner [EMAIL PROTECTED]: The problem I stumbled over was that considering the type of = (=): Monad m = m a - (a - m b) - m b means that I can not „look ahead what files would be written without actually reading the requested file. Of course this is not always possible,

Re: [Haskell-cafe] sdl-mixer loading issue

2008-06-24 Thread Luke Palmer
On Tue, Jun 24, 2008 at 6:34 PM, Norbert Wojtowicz [EMAIL PROTECTED] wrote: Attached is a patched version of SDL_mixer 0.5.2 with a C wrapper for this macro. I'm now able to run loadWAV in ghci. Works for me, thanks! Now I just need to learn how to make my WAVs sound not like

Re: [Haskell-cafe] What is a rigid type variable?

2008-06-23 Thread Luke Palmer
On Mon, Jun 23, 2008 at 5:58 AM, Luke Palmer [EMAIL PROTECTED] wrote: On Mon, Jun 23, 2008 at 3:26 AM, Xiao-Yong Jin [EMAIL PROTECTED] wrote: Hi all, I'm writing a short function as follows, but I'm not able to find a suitable type signature for `go'. It uses Numeric.LinearAlgebra from

Re: [Haskell-cafe] number-parameterized types and heterogeneous lists

2008-06-23 Thread Luke Palmer
On Mon, Jun 23, 2008 at 6:50 AM, Harald ROTTER [EMAIL PROTECTED] wrote: Hello, sorry for the late answer, I was off for the weekend :-) The paper Number-parameterized types by Oleg Kielyov is located at http://okmij.org/ftp/papers/number-parameterized-types.pdf It impressively shows

Re: [Haskell-cafe] Help with generalizing function

2008-06-23 Thread Luke Palmer
On Mon, Jun 23, 2008 at 6:30 AM, leledumbo [EMAIL PROTECTED] wrote: I've successfully create a function to return lists of N-ple that satisfy the following function: x1 + x2 + x3 + ... + xN = C But unfortunately, it's not generic. The N is supposed to be an input, too. I don't know how to

Re: [Haskell-cafe] What is a rigid type variable?

2008-06-22 Thread Luke Palmer
On Mon, Jun 23, 2008 at 3:26 AM, Xiao-Yong Jin [EMAIL PROTECTED] wrote: Hi all, I'm writing a short function as follows, but I'm not able to find a suitable type signature for `go'. It uses Numeric.LinearAlgebra from hmatrix. -- | Map each element in a vector to vectors and thus form a

Re: [Haskell-cafe] Pretty little definitions of left and right folds

2008-06-21 Thread Luke Palmer
On Sat, Jun 21, 2008 at 7:11 PM, Brent Yorgey [EMAIL PROTECTED] wrote: First, given finite sets A (representing an 'alphabet') and S (representing 'states'), we can describe a finite state machine by a function phi : A x S - S, which gives 'transition rules' giving a new state for each

Re: [Haskell-cafe] Haskell's type system

2008-06-18 Thread Luke Palmer
On Tue, Jun 17, 2008 at 2:40 PM, Ron Alford [EMAIL PROTECTED] wrote: I'm trying to wrap my head around the theoretical aspects of haskell's type system. Is there a discussion of the topic separate from the language itself? Since I come from a rather logic-y background, I have this

Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Luke Palmer
On Wed, Jun 18, 2008 at 1:42 PM, PR Stanley [EMAIL PROTECTED] wrote: Now, if you, Jules, Alex or some other wannabe Hitler have a problem with my freedom of expression then your best solution is to saddle up and get the hell out yourselves. This is the wrong place for setting up your tinpot

Re: [Haskell-cafe] Lambda and closures in PHP -- could someone please comment?

2008-06-18 Thread Luke Palmer
On Tue, Jun 17, 2008 at 4:45 PM, Karoly Negyesi [EMAIL PROTECTED] wrote: Hi, The PHP community is discussing the adding of closures and lambdas to the language, see the proposal at http://wiki.php.net/rfc/closures If someone with knowledge of both languages could take a quick look it would

Re: [Haskell-cafe] Newbie Q: Overloading and type classes

2008-06-08 Thread Luke Palmer
On Sat, Jun 7, 2008 at 5:07 PM, Dmitri O.Kondratiev [EMAIL PROTECTED] wrote: {-- And what does the word newbie imply to you when answering my question? In what case using 'fundeps' and 'associated types' will make sence for this example? --} Well, functional dependencies (fundeps) and

Re: [Haskell-cafe] FunPtr error?

2008-06-08 Thread Luke Palmer
2008/6/8 Galchin, Vasili [EMAIL PROTECTED]: Hello, I am getting what is to me a mysterious error in a test case that I am writing: [EMAIL PROTECTED]:~/FTP/Haskell/unix-2.2.0.0/tests/timer$ runhaskell Setup.lhs build Preprocessing executables for Test-1.0... Building Test-1.0... [1 of

Re: [Haskell-cafe] Question about kinds

2008-06-07 Thread Luke Palmer
On Fri, Jun 6, 2008 at 4:41 PM, Klaus Ostermann [EMAIL PROTECTED] wrote: type Id a = a x :: Id Int x = undefined y :: (a Int) - (a Int) y = undefined In a Int, a refers to any type constructor, not any type function. So the best you can do is: newtype Id a = Id a -- rest as before Luke

Re: [Haskell-cafe] Newbie Q: Overloading and type classes

2008-06-07 Thread Luke Palmer
2008/6/7 Dmitri O.Kondratiev [EMAIL PROTECTED]: class Store s where put :: Eq k = (k, v) - s - s get :: k s - Maybe v I suspect you want this to be a constructor class. That is, you want to make explicit the fact that the type s depends on k and v. class Store s where put :: Eq

Re: [Haskell-cafe] Newbie Q: Overloading and type classes

2008-06-07 Thread Luke Palmer
On Sat, Jun 7, 2008 at 1:08 PM, Luke Palmer [EMAIL PROTECTED] wrote: 2008/6/7 Dmitri O.Kondratiev [EMAIL PROTECTED]: class Store s where put :: Eq k = (k, v) - s - s get :: k s - Maybe v I suspect you want this to be a constructor class. That is, you want to make explicit the fact

Re: [Haskell-cafe] More on performance

2008-06-04 Thread Luke Palmer
On Wed, Jun 4, 2008 at 9:48 AM, Loup Vaillant [EMAIL PROTECTED] wrote: I see a problem with this particular fusion, though: It changes the space complexity of the program, from linear to constant. Therefore, with some programs, relying on this optimization can be a matter of correctness, not

Re: [Haskell-cafe] A simple beginner question

2008-06-03 Thread Luke Palmer
On Tue, Jun 3, 2008 at 6:48 PM, Ronald Guida [EMAIL PROTECTED] wrote: filter (\x - case x of A - True; otherwise - False) sampleTypes == [A] filter (\x - case x of B _ - True; otherwise - False) sampleTypes == [B 5] There's a neat little mini-trick for these types of pattern matches:

Re: Re: [Haskell-cafe] Aren't type system extensions fun? [Further analysis]

2008-05-29 Thread Luke Palmer
On Thu, May 29, 2008 at 9:51 AM, Kim-Ee Yeoh [EMAIL PROTECTED] wrote: Roberto Zunino-2 wrote: Alas, for code like yours: foo = \f - (f 'J', f True) there are infinite valid types too: (forall a. a - Int) - (Int, Int) (forall a. a - Char)- (Char, Char) (forall a. a - (a,a)) -

Re: [Haskell-cafe] Re: Aren't type system extensions fun? [Further analysis]

2008-05-27 Thread Luke Palmer
On Tue, May 27, 2008 at 5:55 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Gleb Alexeyev wrote: foo :: (forall a . a - a) - (Bool, String) foo g = (g True, g bzzt) So, after an entire day of boggling my mind over this, I have brought it down to one simple example: (id 'J', id True) --

Re: [Haskell-cafe] Data.Tree.Zipper in the standard libraries

2008-05-23 Thread Luke Palmer
On Fri, May 23, 2008 at 10:55 AM, Jules Bean [EMAIL PROTECTED] wrote: Krasimir Angelov wrote: The monads design is used in Data.Map i.e. lookup :: (Monad m, Ord k) = k - Map k a - m a which is widely considered a poor design decision and a wart on Data.Map. It is? Can you point to

[Haskell-cafe] Newbie: State monad example questions

2008-05-19 Thread Luke Palmer
Hi Dmitri. I'm just going to ramble on about what I know and how I think of things, and maybe you'll pick something up :-) On 5/19/08, Dmitri O.Kondratiev [EMAIL PROTECTED] wrote: getAny :: (Random a) = State StdGen a getAny = do g - get (x,g') - return $ random g

Re: [Haskell-cafe] Re: Another optimization question

2008-05-18 Thread Luke Palmer
On Sat, May 17, 2008 at 11:45 PM, Jeroen [EMAIL PROTECTED] wrote: I only tested with -O2 and my primes implementation is the Sieve of Eratosthenes and has signature primes :: Integral a = [a] I'm guessing that you already know this, but this declares that primes should *not* be cached

Re: [Haskell-cafe] Mapping Haskell Concepts To C# 3

2008-05-18 Thread Luke Palmer
2008/5/17 Kaveh Shahbazian [EMAIL PROTECTED]: 3 - What is the logical implementation of pattern matching in C#? (For example using structures with indicator fields or using interfaces and inheritance and dynamically dispatch in calling overloaded methods. Also this question contain a hidden

Re: [Haskell-cafe] Type inference; always

2008-05-18 Thread Luke Palmer
2008/5/18 Peter Verswyvelen [EMAIL PROTECTED]: In Haskell, I sometimes have to annotate code with type info because the type-inferer otherwise fails (even with -XNoMonomorphismRestriction). Surely, most of the time this is because I was writing buggy code, but sometimes, type annotation just

Re: [Haskell-cafe] Question on declaring an instance

2008-05-18 Thread Luke Palmer
On Mon, May 19, 2008 at 2:02 AM, john lask [EMAIL PROTECTED] wrote: Consider the data type: Foo i o a = ... we want to declare an instance of Monad and Arrow for Foo without using a newtype (repackaging). The effect we want is to be able to construct an expression like: ( f g ) ( h i

Re: [Haskell-cafe] another Newbie performance question

2008-05-17 Thread Luke Palmer
On Sat, May 17, 2008 at 5:22 PM, Philip Müller [EMAIL PROTECTED] wrote: If someone here finds the time to look at my code and give me some hints, that would really be nice. A little experimentation reveals that your main bottleneck is readCSVLine: readCSVLine = read . (\x - [ ++ x ++ ]) (I

Re: [Haskell-cafe] Two-iteration optimisation (was: GHC Predictability)

2008-05-15 Thread Luke Palmer
On Thu, May 15, 2008 at 8:45 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Yitzchak Gale wrote: And of course, you wouldn't want that: f xs = xs : map expensiveCalculation xs Please don't fuse those two loops into one. ...doesn't type check. Did you mean (++)? Hmm? While the name might

Re: [Haskell-cafe] Re: Order of Evaluation

2008-05-11 Thread Luke Palmer
On Fri, May 9, 2008 at 3:46 PM, Achim Schneider [EMAIL PROTECTED] wrote: Miguel Mitrofanov [EMAIL PROTECTED] wrote: Oh, you sure? I was, until you wrote that. But then, I am, as I wouldn't use unsafePerformIO together with IORef's, it's giving me the creeps. So.. what do you use

Re: [Haskell-cafe] Newbie Question: Using Haskell Functions in a C Program

2008-05-11 Thread Luke Palmer
On Thu, May 8, 2008 at 5:09 PM, Philip Müller [EMAIL PROTECTED] wrote: Thanks for all the answers. I'm testing this right now and simples cases work as expected. However from what I've read it seems it'll get ugly once I try to pass a C array to a Haskell function. Well, maybe arrays in C

Re: [Haskell-cafe] Induction (help!)

2008-05-07 Thread Luke Palmer
On Wed, May 7, 2008 at 9:27 PM, PR Stanley [EMAIL PROTECTED] wrote: Hi One of you chaps mentioned the Nat data type data Nat = Zero | Succ Nat Let's have add :: Nat - Nat - Nat add Zero n = n add (Succ m)n = Succ (add m n) Prove add m Zero = m To prove this by induction on m,

Re: [Haskell-cafe] Re: Induction (help!)

2008-05-06 Thread Luke Palmer
On Tue, May 6, 2008 at 4:53 AM, Achim Schneider [EMAIL PROTECTED] wrote: PR Stanley [EMAIL PROTECTED] wrote: Hi I don't know what it is that I'm not getting where mathematical induction is concerned. This is relevant to Haskell so I wonder if any of you gents could explain in

Re: [Haskell-cafe] Induction (help!)

2008-05-06 Thread Luke Palmer
After you grok induction over the naturals, you can start to think about structural induction, which is usually what we use in programming. They are related, and understanding one will help you understand the other (structural induction actually made more sense to me when I was learning, because

Re: [Haskell-cafe] Haskell PNG Writer

2008-05-04 Thread Luke Palmer
SDL-image (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SDL-image-0.5.2) also supports this. Luke On Sun, May 4, 2008 at 12:12 AM, Nahuel Rullo [EMAIL PROTECTED] wrote: Hi list, i am new in Haskell. I need to make images (PNG, JPEG) with haskell, if you can give me a tutorial,

Re: [Haskell-cafe] really difficult for a beginner like me...

2008-05-04 Thread Luke Palmer
2008/5/4 Ivan Amarquaye [EMAIL PROTECTED]: Hi everyone, this is my first posting on here and this was what drove me here and the quest to know more as i anticipate a lot of help and direction in this quite new and different environment haskell.I have this paper that i'm working on and need

Re: [Haskell-cafe] elementary Maybe Monad problem .. sigh

2008-05-01 Thread Luke Palmer
2008/5/2 Galchin, Vasili [EMAIL PROTECTED]: data Bozo = Bozo { id :: Int } bonzo :: Maybe Bozo - IO () bonzo maybe_bozo = do if maybe_bozo == (Just (Bozo x)) then return () else return () bonzo maybe_bozo = case maybe_bozo of

Re: [Haskell-cafe] Mutual recursive data types

2008-04-29 Thread Luke Palmer
On Tue, Apr 29, 2008 at 8:54 AM, rodrigo.bonifacio [EMAIL PROTECTED] wrote: Hi all, I have the following data types: type Id = String type Action = String type State = String type Response = String data Scenario = Scenario Description [Step] data Step = Step Id Scenario Action

Re: [Haskell-cafe] Confused by instances

2008-04-28 Thread Luke Palmer
2008/4/28 Fraser Wilson [EMAIL PROTECTED]: On Mon, Apr 28, 2008 at 10:50 PM, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: The format is instance [context =] classname instance. Your classname is ValueClass. Your instance is a. a is not of the form (T a1 ... an). But neither is

Re: [Haskell-cafe] Confused by instances

2008-04-28 Thread Luke Palmer
2008/4/28 Fraser Wilson [EMAIL PROTECTED]: what I am trying to say is if a is an instance of Num, then can be an instance of ValueClass too, and here's how. Oh, didn't answer this one. This is almost canned response, questions like this get asked weekly on this list. Short answer: you can't.

Re: [Haskell-cafe] Confused by instances

2008-04-28 Thread Luke Palmer
On Mon, Apr 28, 2008 at 3:47 PM, Fraser Wilson [EMAIL PROTECTED] wrote: On Mon, Apr 28, 2008 at 11:33 PM, Luke Palmer [EMAIL PROTECTED] wrote: To answer your other question, no, there is no list show hack. Perhaps hack was a strong word. I'm not referring to type synonyms, but to the fact

Re: [Haskell-cafe] pls help about subtree

2008-04-28 Thread Luke Palmer
2008/4/28 cetin tozkoparan [EMAIL PROTECTED]: Assume a tree is a subtree of the other if all elements of the first tree is included in the second with the exact structure; all parent-child relations are preserved with their order. data Tree = Empty | Leaf Int | Node (Int,Tree,Tree) Bit of a

Re: [Haskell-cafe] mapM vs mapM_ performance

2008-04-24 Thread Luke Palmer
On Tue, Apr 22, 2008 at 11:32 AM, Ben [EMAIL PROTECTED] wrote: Hello Haskellers, I'm running ghc 6.8.2 on vista 64. Consider the following program, which is compiled with -02 -prof -auto-all: module Main where import System.IO (openFile, IOMode(..), hPutStr) testlst = let ls = [(i,

Re: [Haskell-cafe] functional update

2008-04-24 Thread Luke Palmer
On Tue, Apr 22, 2008 at 6:26 AM, Henning Thielemann [EMAIL PROTECTED] wrote: On Mon, 21 Apr 2008, Ryan Ingram wrote: I recommend this blog entry: http://twan.home.fmf.nl/blog/haskell/overloading-functional-references.details along with a few additional combinators for imperative update:

Re: Re[2]: a faster, accumulating mapM (was Re: [Haskell-cafe] mapM vs mapM_ performance)

2008-04-24 Thread Luke Palmer
On Thu, Apr 24, 2008 at 11:28 PM, Ben [EMAIL PROTECTED] wrote: 2) Is there a reason to not use mapM3 above? Yes, there certainly is. mapM3 is not equivalent to mapM; it is too strict: *Main take 3 $ head $ mapM return [1,2,3,4,undefined] [1,2,3] *Main take 3 $ head $ mapM3 return

Re: [Haskell-cafe] Help me refactor this type!

2008-04-24 Thread Luke Palmer
On Thu, Apr 24, 2008 at 11:10 PM, Ryan Ingram [EMAIL PROTECTED] wrote: More FRP stuff: a new type for Future that came to me in an inspiration this morning. But it's ugly and I need someone with better theoretical underpinnings than me to tell me what I've really built :) data Future t

Re: Re[2]: a faster, accumulating mapM (was Re: [Haskell-cafe] mapM vs mapM_ performance)

2008-04-24 Thread Luke Palmer
On Fri, Apr 25, 2008 at 12:02 AM, Ben [EMAIL PROTECTED] wrote: Luke, Thanks for the nice answer. So maybe I'll give mapM3 the name mapM' and put it in my personal library. Except the answer was wrong. I forgot the reverse in my implementation, so that undefined we were seeing was just the

Re: [Haskell-cafe] Re: Embedding newlines into a string?

2008-04-14 Thread Luke Palmer
On Tue, Apr 15, 2008 at 3:45 AM, Benjamin L. Russell [EMAIL PROTECTED] wrote: hanoi_shower ((a, b) : moves) | null moves = Move ++ show a ++ to ++ show b ++ . | otherwise == Move ++ show a ++ to ++ show b ++ . ++ hanoi_shower moves More idiomatic pedantry: the way you will see

Re: [Haskell-cafe] install trouble with SDL on win32+cygwin

2008-04-11 Thread Luke Palmer
2008/4/11 Conal Elliott [EMAIL PROTECTED]: I'm trying to install the SDL package (on win32+cygwin), and configure isn't able to find my SDL.dll, though it's on my PATH. Any ideas? - Conal bash-3.2$ cabal install SDL 'SDL-0.5.3' is cached. [1 of 1] Compiling Main ( Setup.lhs,

Re: [Haskell-cafe] Fighting the monad stack, MonadIO

2008-04-10 Thread Luke Palmer
On Thu, Apr 10, 2008 at 2:50 PM, Adam Smyczek [EMAIL PROTECTED] wrote: For a small webapi binding I try to implement a session like monad by building a stack including BrowserAction from Network.Browser module as following: newtype RBAction a = RBAction { exec :: ErrorT String (StateT

Re: [Haskell-cafe] Pattern match failure

2008-04-09 Thread Luke Palmer
On Thu, Apr 10, 2008 at 2:05 AM, Jackm139 [EMAIL PROTECTED] wrote: I'm trying to write a function to recognize a context free grammar, but I keep getting pattern match failure errors. This is what I have: data Grammar c = Brule c c c | Rule c c gez = [(Brule 'S' 'p' 'D'),(Brule 'D' 't'

[Haskell-cafe] ANN: graphics-drawingcombinators 0.1

2008-04-08 Thread Luke Palmer
graphics-drawingcombinators 0.1 has just been uploaded to hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/graphics-drawingcombinators-0.1 Have you ever tried to write a simple 2D interface or game but found: * wxHaskell and gtk2hs are hard to install and learn * SDL does

Re: [Haskell-cafe] Beginners arrow question

2008-04-05 Thread Luke Palmer
On Sat, Apr 5, 2008 at 4:00 PM, Cale Gibbard [EMAIL PROTECTED] wrote: GHC has a special syntax for using ArrowApply (which HXT is an instance of). Whenever the expression to the left of - needs to involve a local variable, you can replace - with - and it should work. To understand better

Re: [Haskell-cafe] Typing with co/contra-variance.

2008-04-03 Thread Luke Palmer
On Thu, Apr 3, 2008 at 9:58 AM, Ben Lippmeier [EMAIL PROTECTED] wrote: Hi all, I have some quick questions for the type theory people: If I write an expression: (if .. then 23 else Erk) In Haskell this would be an error, but perhaps I can assign it the type 'Top' (or 'Any') and then

Re: [Haskell-cafe] Role based access control via monads or arrows or... something

2008-04-02 Thread Luke Palmer
2008/4/2 porrifolius [EMAIL PROTECTED]: (7) ideally required permissions would appear (and accumulate) in type signatures via inference so application code knows which are required and type checker can reject static/dynamic role constraint violations If you mean what I think you mean by

Re: [Haskell-cafe] [Newbie] Problem with Data.Map (or something else ?)

2008-03-31 Thread Luke Palmer
On Mon, Mar 31, 2008 at 6:00 PM, Bruno Carnazzi [EMAIL PROTECTED] wrote: I've done this modification with no more success : import qualified Data.List as List import qualified Data.Map as Map f :: Integer - Integer f n | even n = n `div` 2 | otherwise = 3 * n + 1 chain m n =

Re: [Haskell-cafe] Glome raytracer bug: bad output with -O2 -fasm

2008-03-28 Thread Luke Palmer
On Fri, Mar 28, 2008 at 6:28 AM, Jim Snow [EMAIL PROTECTED] wrote: I was trying to get Blinn highlights working with my raytracer, and kept getting ugly artifacts. After trying a bunch of things, I finally compiled without -O2, and the artifacts went away. Here's what I mean:

Re: [Haskell-cafe] Recursion problem in infinite list model

2008-03-27 Thread Luke Palmer
On Thu, Mar 27, 2008 at 2:18 PM, Claude Heiland-Allen The combination of (-+) and h is too strict, this modification works: (-+) :: a - List a - List a x -+ ~(List y) = List(f) where -- lazy pattern match f 0 = x f k = y(k-1) More to the point, if List is declared as:

Re: [Haskell-cafe] Parsec Expected Type

2008-03-27 Thread Luke Palmer
Hi Paul, 2008/3/27 Paul Keir [EMAIL PROTECTED]: Hi, Does anyone know why this reduced Parsec production stops compilation, and how I can fix it? tester = reserved parameter | do { reserved dimension; symbol : } Look at the types of reserved and symbol (from

Re: [Haskell-cafe] Terminating GLUT/GLFW programs

2008-03-25 Thread Luke Palmer
On Tue, Mar 25, 2008 at 7:37 PM, Paul L [EMAIL PROTECTED] wrote: Peter is right at saying it's the sample GLFW program that didn't handle Window Close event. I didn't double check his modification because I run Linux/X11 with xmonad where there is no CLOSE button for any window, but I trust

Re: [Haskell-cafe] Terminating GLUT/GLFW programs

2008-03-25 Thread Luke Palmer
Er, not Ctrl, of course... Mod-Shift-C. /me goes to punish his hand for compusive send presses. On Tue, Mar 25, 2008 at 10:40 PM, Luke Palmer [EMAIL PROTECTED] wrote: On Tue, Mar 25, 2008 at 7:37 PM, Paul L [EMAIL PROTECTED] wrote: Peter is right at saying it's the sample GLFW program

Re: [Haskell-cafe] Type constraints for class instances

2008-03-20 Thread Luke Palmer
First I'd like to say that this is a very clever idea. Thanks for the exposition. :-) 2008/3/21 Krzysztof Skrzętnicki [EMAIL PROTECTED]: I'd like to write the following code: instance (Ord a) = YOrd a where ycmp x y = case x `compare` y of LT - (x,y)

Re: [Haskell-cafe] Small question about something easy

2008-03-18 Thread Luke Palmer
On Tue, Mar 18, 2008 at 12:24 PM, iliali16 [EMAIL PROTECTED] wrote: Now the problem comes here: play (p1 :: p2) state |play p1 state == (i1,state1) play p2 state1 == (i2,state2) = (i1+++i2,state2) I know that if I manage to do that function the one above with this sign ::

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-13 Thread Luke Palmer
On Wed, Mar 12, 2008 at 4:45 PM, Donn Cave [EMAIL PROTECTED] wrote: Well, the problem inherently requires a certain order of evaluation. But if you will just handle pattern match failure in the IO monad, then you can write a simple functional expression of the problem instead, let

Re: [Haskell-cafe] Re: (flawed?) benchmark : sort

2008-03-13 Thread Luke Palmer
On Thu, Mar 13, 2008 at 1:00 AM, Adrian Hey [EMAIL PROTECTED] wrote: AFAICT the report is ambiguous about this, or at least the non-intutive equality semantics are not at all clear to me from what I can see in the Eq class definition (para 6.3.1). I think an the absence of any clear and

Re: [Haskell-cafe] Re: (flawed?) benchmark : sort

2008-03-13 Thread Luke Palmer
On Thu, Mar 13, 2008 at 3:02 AM, Adrian Hey [EMAIL PROTECTED] wrote: The report doesn't state that for all Ints, (x==y = True) implies that x=y. There's no reason to suppose the Int instance is in any way special, so do you really seriously consider the possibility that this might not hold

Re: [Haskell-cafe] Exception handling when using STUArray

2008-03-10 Thread Luke Palmer
On Mon, Mar 10, 2008 at 7:37 AM, Donn Cave [EMAIL PROTECTED] wrote: On Mar 9, 2008, at 1:07 PM, Henning Thielemann wrote: Errors are programming errors and must be fixed as Denis explained. Thus there is no need for a complex system of handling these situations at run-time. The

Re: [Haskell-cafe] Re: (flawed?) benchmark : sort

2008-03-10 Thread Luke Palmer
On Mon, Mar 10, 2008 at 11:00 AM, Adrian Hey [EMAIL PROTECTED] wrote: Neil Mitchell wrote: 2) What does it do with duplicate elements in the list? I expect it deletes them. To avoid this, you'd need to use something like fromListWith, keeping track of how many duplicates there

Re: [Haskell-cafe] IO () and IO [()]

2008-03-10 Thread Luke Palmer
2008/3/10 Krzysztof Skrzętnicki [EMAIL PROTECTED]: In Python the syntax to create 1-tuple is (element,). Note the ,. It's not the most beautiful but is acceptable. But that syntax ought to be for tuple sections. Is there a good reason that Haskell doesn't have tuple sections? (hello, world)

Re: [Haskell-cafe] reply to vincent foley's question about poker

2008-03-08 Thread Luke Palmer
On Sun, Mar 9, 2008 at 3:21 AM, Thomas Hartman [EMAIL PROTECTED] wrote: instance (Enum a, Bounded a) = Arbitrary a where arbitrary = do n - choose (fromEnum (minBound :: a), fromEnum (maxBound :: a) ) return $ toEnum n I really think it's a bad idea to allow undecidable

Re: [Haskell-cafe] deriving instances of Enum for tuples of bounded, enumerable types (useful for generating QuickCheck.Arbitrary instances for collection of collection types)

2008-03-08 Thread Luke Palmer
On Sun, Mar 9, 2008 at 3:23 AM, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: myFunc :: (forall a. (Bounded a, Enum a) = a) - (forall a. (Bounded a, Enum a) = a) - (forall a. (Bounded a, Enum a) = a) which is a rather useless declaration (I think the only

Re: [Haskell-cafe] Issues(Bugs?) with GHC Type Families

2008-03-06 Thread Luke Palmer
On Thu, Mar 6, 2008 at 7:52 PM, Ryan Ingram [EMAIL PROTECTED] wrote: I wish there was some form of instance declaration that let you do case analysis; something similar to the following: instances C [a] where instance C String where c = a instance C a = C [a] where

Re: [Haskell-cafe] Doubting Haskell

2008-03-04 Thread Luke Palmer
On Tue, Mar 4, 2008 at 4:16 AM, Ketil Malde [EMAIL PROTECTED] wrote: Paul Johnson [EMAIL PROTECTED] writes: I'm surprised you found the significant whitespace difficult. I wonder if this has something to do with the editor one uses? I use Emacs, and just keep hitting TAB, cycling

Re: [Haskell-cafe] coerce (safe!)

2008-03-02 Thread Luke Palmer
2008/3/2 Roman Cheplyaka [EMAIL PROTECTED]: * Krzysztof Skrzętnicki [EMAIL PROTECTED] [2008-03-02 01:21:42+0100] Well, it is simply coerce :: a - b coerce _ = undefined so coerce is simply empty function. But still, it is possible to write a function of type (a-b). Well,

Re: [Haskell-cafe] Space leak - help needed

2008-03-02 Thread Luke Palmer
On Mon, Mar 3, 2008 at 2:23 AM, Krzysztof Kościuszkiewicz [EMAIL PROTECTED] wrote: Dear Haskellers, Another story from an (almost) happy Haskell user that finds himself overwhelmed by laziness/space leaks. I'm trying to parse a large file (600MB) with a single S-expression like

Re: [Haskell-cafe] Generating a random list

2008-03-01 Thread Luke Palmer
On Sat, Mar 1, 2008 at 8:18 AM, Milos Hasan [EMAIL PROTECTED] wrote: Here's a minimal summing example that illustrates the difference. The following works fine, since the elements are generated lazily and summed on the fly, as expected: randFloats :: [Float] randFloats = randoms

Re: [Haskell-cafe] Generating a random list

2008-02-29 Thread Luke Palmer
On Sat, Mar 1, 2008 at 6:50 AM, Milos Hasan [EMAIL PROTECTED] wrote: Hi, so let's say I want to generate a list of N random floats. The elegant way of doing it would be to create an infinite lazy list of floats and take the first N, but for N = 1,000,000 or more, this overflows the

Re: [Haskell-cafe] Wrong kind when attempting to build a monad for a circular list of functions

2008-02-27 Thread Luke Palmer
On Thu, Feb 28, 2008 at 7:28 AM, Aaron Altman [EMAIL PROTECTED] wrote: newtype CircularFuncList funcList arg = CircularFuncList (funcList - arg - (arg, funcList)) instance Monad (CircularFuncList funcList arg) where return a = CircularFuncList (\funcList a - (a, funcList))

Re: [Haskell-cafe] naming a data structure for weighted random selection without replacement

2008-02-18 Thread Luke Palmer
On Feb 18, 2008 5:11 AM, Stuart Cook [EMAIL PROTECTED] wrote: A while ago I wrote a little data structure that allows weighted random selection-without-replacement from a collection of values in O(log n) time.[1] I'm now in the process of packaging it up for Hackage, but I'm looking for good

Re: [Haskell-cafe] Rendering TTF fonts in Haskell and OpenGL

2008-02-17 Thread Luke Palmer
On Feb 18, 2008 12:20 AM, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: On Feb 17, 2008, at 19:13 , Jefferson Heard wrote: In C and in Java, I can use truetype fonts in Haskell using select libraries, and I'd like to be able to do the same in Haskell. Are there any portable libraries

Re: [Haskell-cafe] Designing a Parser

2008-02-16 Thread Luke Palmer
On Feb 17, 2008 6:20 AM, PR Stanley [EMAIL PROTECTED] wrote: I can't think of an elegant pattern for the last function. I've already tried set comprehension. However, something tells me that the answer may lie in a complex recursive pattern. I'm not afraid of complex solutions but I

Re: [Haskell-cafe] a general question on Arrows

2008-02-14 Thread Luke Palmer
On Thu, Feb 14, 2008 at 12:50 AM, Steve Lihn [EMAIL PROTECTED] wrote: He described a few things that cannot be represented as a monad, they are: 1. Stream This is actually a comonad. 2. FRP Depends on which FRP you're talking about. This could be the stream comonoad + the event monad.

Re: [Haskell-cafe] a general question on Arrows

2008-02-14 Thread Luke Palmer
On Thu, Feb 14, 2008 at 7:34 PM, Steve Lihn [EMAIL PROTECTED] wrote: I have a small question on the simulation technique. In both John Hughes and your code, you wrap the print inside the runXYZ (...) to print out the state of simulation. It is like: runArrow ( ... simulation ...then print

Re: [Haskell-cafe] Designing DSL with explicit sharing [was: I love purity, but it's killing me]

2008-02-13 Thread Luke Palmer
On Feb 13, 2008 9:33 AM, [EMAIL PROTECTED] wrote: The approach is based on the final tagless representation. Here is our DSL: class Exp repr where constant :: Int - repr Int variable :: String - repr Int add :: repr Int - repr Int - repr Int sub :: repr Int - repr Int -

Re: [Haskell-cafe] A question about monad laws

2008-02-12 Thread Luke Palmer
2008/2/12 Uwe Hollerbach [EMAIL PROTECTED]: Well... I dunno. Looking at the source to GHC.Real, I see infinity, notANumber :: Rational infinity = 1 :% 0 notANumber = 0 :% 0 This is actually the reason I imported GHC.Real, because just plain % normalizes the rational number it creates,

Re: [Haskell-cafe] question about STM and IO

2008-02-12 Thread Luke Palmer
On Feb 12, 2008 6:28 PM, John Lato [EMAIL PROTECTED] wrote: Hello, I was recently looking at the STM library, and I have a question about the function unsafeIOToSTM. Can anyone explain to me what is unsafe about it, and what sort of use would be considered safe? A few things. First, this

Re: [Haskell-cafe] f(g(x), h(y)) - Correct syntax

2008-02-11 Thread Luke Palmer
On Feb 11, 2008 2:27 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hallo! I have this code: q1 :: EName - [ApprenticeInfo] q1 c = [apprenticeInfo n | n - allApprentices, member ((sq4 c) (firstOf5(n))) == True] sq4 :: ESurname - [IDB] sq4 c = (sq3

Re: [Haskell-cafe] Embedded Functions in Algebraic Data Types?

2008-02-10 Thread Luke Palmer
Quite frequently. Here are a few examples from my own code: For functional references (representing a bidirectional function from a data type to a part of itself (for example the first element of a pair)). data Accessor s a = Accessor { get :: s - a , set :: a - s - s

Re: [Haskell-cafe] Inverting a Monad

2008-02-06 Thread Luke Palmer
On Feb 6, 2008 11:32 AM, Bas van Dijk [EMAIL PROTECTED] wrote: The following obviously doesn't work: inv m = (m mzero) `mplus` return () because it will always return (). How about: inv m = do success - (m return True) `mplus` return False if success then mzero else return ()

Re: [Haskell-cafe] background question about IO monad

2008-02-06 Thread Luke Palmer
On Feb 7, 2008 7:32 AM, Uwe Hollerbach [EMAIL PROTECTED] wrote: pure_fn :: Integer - String pure_fn n = calendarTimeToString (toUTCTime (TOD n 0)) make_wicked :: String - IO String make_wicked str = return str -- use of make_wicked main = (make_wicked (pure_fn 1234567890)) =

Re: [Haskell-cafe] Haskell maximum stack depth

2008-02-05 Thread Luke Palmer
On Feb 5, 2008 2:50 AM, Adrian Hey [EMAIL PROTECTED] wrote: I think it bites a lot less often than it otherwise would because most people will deliberately chose to use heap in preference to stack (at least when writing eager code) just to avoid the problem. But it still bites pretty often

Re: [Haskell-cafe] Parameterisations of Monads

2008-02-05 Thread Luke Palmer
On Feb 5, 2008 7:48 AM, Matthew Sackman [EMAIL PROTECTED] wrote: So I was thinking how dull and uninspiring the current definiton of Monad really is and came up with some more interesting parameterisations. The only problem with this one is I'm a) not sure if it still is a Monad and b) very

Re: [Haskell-cafe] Mutable arrays

2008-02-05 Thread Luke Palmer
On Feb 5, 2008 4:36 PM, Jeff φ [EMAIL PROTECTED] wrote: I want to say thanks to everyone who responded to my mutable array post. I'm going to work through and experiment with all the comments people posted. It might take me a while. Luke Palmer wrote: Hmm, how big is the array? If it's

Re: [Haskell-cafe] Haskell maximum stack depth

2008-02-05 Thread Luke Palmer
On Feb 5, 2008 6:50 PM, Adrian Hey [EMAIL PROTECTED] wrote: Luke Palmer wrote: On Feb 5, 2008 2:50 AM, Adrian Hey [EMAIL PROTECTED] wrote: I think it bites a lot less often than it otherwise would because most people will deliberately chose to use heap in preference to stack (at least

Re: [Haskell-cafe] background question about IO monad

2008-02-05 Thread Luke Palmer
On Feb 5, 2008 9:44 PM, Uwe Hollerbach [EMAIL PROTECTED] wrote: lisp (UTCtime) Wed Feb 6 03:57:45 UTC 2008 --- lisp (UTCtime 1.203e9) Thu Feb 14 14:40:00 UTC 2008 -- But after that, it sure seems to me as if I've taken data out of the IO monad... haven't I? Given that the second

Re: [Haskell-cafe] Mutable arrays

2008-02-02 Thread Luke Palmer
I prerequest your forgiveness if I sound patronizing, I'm just writing everything that comes to mind. 2008/2/2 Jeff φ [EMAIL PROTECTED]: {-# OPTIONS_GHC -fglasgow-exts -fbreak-on-exception #-} -- normalize_ary This takes a mutable array. Determines the largest -- element in the array

Re: [Haskell-cafe] newbie q about types

2008-02-01 Thread Luke Palmer
Look at the type of tail: tail :: [a] - [a] That is, tail is the list of all elements *except* the head. You want last. (Barring style considerations. Usually in a situation like this you would use a list of tuples rather than a list of lists, since then you know at compile time that you have

Re: [Haskell-cafe] Deleting list of elements from Data.Set

2008-01-30 Thread Luke Palmer
On Jan 30, 2008 11:05 AM, Gracjan Polak [EMAIL PROTECTED] wrote: My strictness analyser in my brain hurts. Which one (foldl,foldl',foldr) is the best way? Prelude Data.Set Data.List let s = fromList [1,2,3,4,5] Loading package array-0.1.0.0 ... linking ... done. Loading package

Re: [Haskell-cafe] Re: Why purely in haskell?

2008-01-14 Thread Luke Palmer
On Jan 15, 2008 12:29 AM, [EMAIL PROTECTED] wrote: Ben Franksen writes: [EMAIL PROTECTED] wrote: ... Does *MATH* answer the question what is: (0/0)==(0/0) ? Nope! Exactly. So why try to give an answer in Haskell? MATH says: the expression 0/0 is undefined, thus comparing (0/0)==(0/0)

Re: [Haskell-cafe] Solving a geometry problem with Haskell

2008-01-12 Thread Luke Palmer
On Jan 12, 2008 9:19 PM, Rafael Almeida [EMAIL PROTECTED] wrote: After some profiling I found out that about 94% of the execution time is spent in the ``isPerfectSquare'' function. That function is quite inefficient for large numbers. You might try something like this: isPerfectSquare n =

Re: [Haskell-cafe] Solving a geometry problem with Haskell

2008-01-12 Thread Luke Palmer
speed boost. Luke On Jan 12, 2008 9:48 PM, Luke Palmer [EMAIL PROTECTED] wrote: On Jan 12, 2008 9:19 PM, Rafael Almeida [EMAIL PROTECTED] wrote: After some profiling I found out that about 94% of the execution time is spent in the ``isPerfectSquare'' function. That function is quite

Re: [Haskell-cafe] [newbie question] Memoization automatic in Haskell?

2008-01-12 Thread Luke Palmer
On Jan 12, 2008 11:30 PM, David Benbennick [EMAIL PROTECTED] wrote: On 1/12/08, Henning Thielemann [EMAIL PROTECTED] wrote: Caching is not the default, but you can easily code this by yourself: Define an array and initialize it with all function values. Because of lazy evaluation the

<    1   2   3   4   5   6   7   >