Re: [Haskell-cafe] Function composition questions from a newbie

2009-12-01 Thread newbie2009
I am a newbie. Consider this code: square x = x * x add3 x y z = x + y + z leledumbo wrote: what about (square . add3) 1 2? It doesn't work since add3, when curried (arguments of square blended with add3's) with 1 argument becomes: add3 :: Num a = a - a - a which is a

Re: [Haskell-cafe] Re: Timing and Atom

2009-12-01 Thread Neil Davies
On 1 Dec 2009, at 05:44, Tom Hawkins wrote: I never considered running Atom generated functions in an asynchronous loop until you posted your Atomic Fibonacci Server example (http://leepike.wordpress.com/2009/05/05/an-atomic-fibonacci-server-exploring-the-atom-haskell-dsl/ ). I'm

Re: [Haskell-cafe] Function composition questions from a newbie

2009-12-01 Thread leledumbo
I dont understand why the above functions are legal, and what arguments they need. Could you please give an example of how to invoke it? Huh? None of them are legal, at least in my WinHugs they're not. What tools are you using? Some good reading I found:

Re: [Haskell-cafe] Function composition questions from a newbie

2009-12-01 Thread newbie2009
leledumbo wrote: None of them are legal, at least in my WinHugs they're not. What tools are you using? 1) I am using GHCi. I put the following into a file named composition.hs and typed :l composition.hs in GHCi. I also did a :browse Main 2) Next, I installed WinHugs, and loaded the same

[Haskell-cafe] Re: Are there standard idioms for lazy, pure error handling?

2009-12-01 Thread Heinrich Apfelmus
Duncan Coutts wrote: On Mon, 2009-11-30 at 06:08 +, Malcolm Wallace wrote: However, if you really want to terminate the stream at the first error, and to reflect this in the type, then I guess you can define your own list type: data ListThenError e a = Cons a (ListThenError e a)

[Haskell-cafe] Re: Help mixing pure and IO code

2009-12-01 Thread Heinrich Apfelmus
Luke Palmer wrote: Hector Guilarte hector...@gmail.com wrote: f:: [int] - (a,[Int]) f randomList = let (usedRandomNumber,newRandomList) = g randomList in (usedRandomNumber,newRandomList) This pattern can be encapsulated in a monad: newtype RandM a = RandM { unRandM :: [Int] -

Re: [Haskell-cafe] Are there standard idioms for lazy, pure error handling?

2009-12-01 Thread Duncan Coutts
On Mon, 2009-11-30 at 20:10 -0800, John Millikin wrote: On Mon, Nov 30, 2009 at 03:02, Duncan Coutts duncan.cou...@googlemail.com wrote: data ListThenError e a = Cons a (ListThenError e a) | Error e Of course this has the disadvantage that then your consumer must

Re: [Haskell-cafe] Re: Are there standard idioms for lazy, pure error handling?

2009-12-01 Thread Nicolas Pouillard
Excerpts from Heinrich Apfelmus's message of Tue Dec 01 11:29:24 +0100 2009: Duncan Coutts wrote: On Mon, 2009-11-30 at 06:08 +, Malcolm Wallace wrote: However, if you really want to terminate the stream at the first error, and to reflect this in the type, then I guess you can

Re: [Haskell-cafe] Re: Are there standard idioms for lazy, pure error handling?

2009-12-01 Thread Mark Lentczner
On Dec 1, 2009, at 2:29 AM, Heinrich Apfelmus wrote: data Train a b = Wagon a (Train a b) | Loco b Surely that should be: data Train a b = Wagon a (Train a b) | Caboose b ? - MtnViewMark Mark Lentczner http://www.ozonehouse.com/mark/

Re: [Haskell-cafe] Function composition questions from a newbie

2009-12-01 Thread Daniel Fischer
Am Dienstag 01 Dezember 2009 10:32:24 schrieb newbie2009: leledumbo wrote: None of them are legal, at least in my WinHugs they're not. What tools are you using? 1) I am using GHCi. I put the following into a file named composition.hs and typed :l composition.hs in GHCi. I also did a

Re: [Haskell-cafe] Great Programs to Read?

2009-12-01 Thread Jason Foutz
I'd suggest the Prelude and Data.List The code is very clear and thoroughly documented. Knowing what is there will pay off again and again. - Jason On Nov 30, 2009, at 5:22 AM, Michael Lesniak wrote: Hello, In terms of to become a great programmer, you need to read great programs[1]

Re: [Haskell-cafe] Great Programs to Read?

2009-12-01 Thread Michael Lesniak
Hello, thanks for all the advices; will have enough to read for the next weeks and months! :-) - Michael -- Dipl.-Inf. Michael C. Lesniak University of Kassel Programming Languages / Methodologies Research Group Department of Computer Science and Electrical Engineering Wilhelmshöher Allee 73

Re: [Haskell-cafe] Re: Are there standard idioms for lazy, pure error handling?

2009-12-01 Thread David Menendez
On Tue, Dec 1, 2009 at 5:29 AM, Heinrich Apfelmus apfel...@quantentunnel.de wrote: Duncan Coutts wrote: On Mon, 2009-11-30 at 06:08 +, Malcolm Wallace wrote: However, if you really want to terminate the stream at the first error, and to reflect this in the type, then I guess you can

[Haskell-cafe] KiCS (Curry to Haskell interpreter) problem

2009-12-01 Thread Pasqualino Titto Assini
Hi, I am playing around with KiCS and I have a strange problem, when I evaluate a goal the variable bindings are not displayed, I see only the value of the expression. The same expression evaluated in pakcs (another curry interpreter) displays the bindings correctly. Is this a known bug? I

[Haskell-cafe] Fwd: Timing and Atom

2009-12-01 Thread Lee Pike
[Tom -- resending my reply---I forgot to post to the list.] Neil, could you provide a reference (more on the practical side than the theory side) for the Stochastic Process Algebras you mention? And is there an embedding in Haskell? :) Lee Begin forwarded message: From: Lee Pike

[Haskell-cafe] Existencial Types

2009-12-01 Thread rodrigo.bonifacio
Dear all, I wrote the following  types: class Transformation t where   (+) :: t - SPLModel  - InstanceModel - InstanceModel data Configuration = forall t . Transformation t = Configuration (FeatureExpression, [t]) type ConfigurationKnowledge = [Configuration]   I tried to write a function that

Re: [Haskell-cafe] Re: ANNOUNCE: Clutterhs 0.1

2009-12-01 Thread Iavor Diatchki
Hi, I work with Trevor on the other Clutter binding. We did exchange a few messages with Matt, but we were not sure how to combine the two libraries because our approaches to writing the binding were a bit different. In general, I don't think that having two similar libraries is a huge problem.

Re: [Haskell-cafe] Existencial Types

2009-12-01 Thread David Menendez
On Tue, Dec 1, 2009 at 1:00 PM, rodrigo.bonifacio rodrigo.bonifa...@uol.com.br wrote: Dear all, I wrote the following  types: class Transformation t where   (+) :: t - SPLModel  - InstanceModel - InstanceModel data Configuration = forall t . Transformation t = Configuration

[Haskell-cafe] Re: ANNOUNCE: Clutterhs 0.1

2009-12-01 Thread Gour
On Tue, 1 Dec 2009 10:06:14 -0800 Iavor == Iavor Diatchki iavor.diatc...@gmail.com wrote: Iavor I work with Trevor on the other Clutter binding. We did Iavor exchange a few messages with Matt, but we were not sure how to Iavor combine the two libraries because our approaches to writing the

[Haskell-cafe] lazy logging (was: Are there standard idioms for lazy, pure error handling?)

2009-12-01 Thread Evan Laforge
This is only peripherally related, but I also have a lot of list functions that can possibly be an error, but usually processing can continue. So they tend to return [Either Error Result]. I have another function thus: -- A foldr version is not lazy enough and overflows the stack.

Re: [Haskell-cafe] lazy logging (was: Are there standard idioms for lazy, pure error handling?)

2009-12-01 Thread Daniel Fischer
Am Dienstag 01 Dezember 2009 20:21:27 schrieb Evan Laforge: This is only peripherally related, but I also have a lot of list functions that can possibly be an error, but usually processing can continue. So they tend to return [Either Error Result]. I have another function thus: -- A foldr

[Haskell-cafe] university courses on type families/GADTs?

2009-12-01 Thread Tom Schrijvers
Hello Haskell Cafe, I was wondering whether there are any universities that teach about Haskell type families or GADTs? Thanks, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail:

Re: [Haskell-cafe] Existencial Types

2009-12-01 Thread Luke Palmer
On Tue, Dec 1, 2009 at 11:21 AM, David Menendez d...@zednenem.com wrote: On Tue, Dec 1, 2009 at 1:00 PM, rodrigo.bonifacio rodrigo.bonifa...@uol.com.br wrote: Dear all, I wrote the following  types: class Transformation t where   (+) :: t - SPLModel  - InstanceModel - InstanceModel data

[Haskell-cafe] module export question

2009-12-01 Thread Sean McLaughlin
Say I have the following module: module A ( T(T) , t , val ) where data T = T { t :: Int } val :: T val = T 7 When I use A with the following imports, I don't expect this to work, but it does: import

Re: [Haskell-cafe] module export question

2009-12-01 Thread Luke Palmer
On Tue, Dec 1, 2009 at 3:11 PM, Sean McLaughlin sean...@gmail.com wrote: Say I have the following module: module A  ( T(T)  , t  , val  ) where data T = T { t :: Int } val :: T val = T 7 When I use

Re: [Haskell-cafe] module export question

2009-12-01 Thread Ross Mellgren
It looks like it is specified and the intended behavior: From the report, section 5.2: An algebraic datatype T declared by a data or newtype declaration may be named in one of three ways: The form T names the type but not the constructors or field names. The ability to export a type without

[Haskell-cafe] Re: inversion lists

2009-12-01 Thread Ted Zlatanov
On Fri, 20 Nov 2009 15:30:49 -0600 Ted Zlatanov t...@lifelogs.com wrote: TZ A nice property of inversion lists is that inverting them simply TZ requires removing or adding the minimum possible value at the beginning TZ of the list. A membership test requires traversal but since the list is TZ

Re: [Haskell-cafe] module export question

2009-12-01 Thread Ross Paterson
On Tue, Dec 01, 2009 at 05:11:42PM -0500, Sean McLaughlin wrote: The problem is that I explicitly didn't export 't' as an element of T (by not writing T(..)). Am I just misunderstanding how exports work? I couldn't figure out what the correct behavior should be by looking at the 98 report.

[Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Jeremy Fitzhardinge
I'm playing around with some types to represent a game board (like Go, Chess, Scrabble, etc). I'm using a type class to represent the basic Board interface, so I can change the implementation freely: class Board b pos piece where -- Update board with piece played at pos play :: b pos

[Haskell-cafe] Re: [Haskell] ANN: NoSlow - Microbenchmarks for array libraries

2009-12-01 Thread Henning Thielemann
On Fri, 27 Nov 2009, Henning Thielemann wrote: On Fri, 27 Nov 2009, Roman Leshchinskiy wrote: You can get more information (including the ugly tables) from my blog http://unlines.wordpress.com/2009/11/27/noslow Btw. storablevector supports 'zip' using

Re: [Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Daniel Fischer
Am Dienstag 01 Dezember 2009 23:34:46 schrieb Jeremy Fitzhardinge: I'm playing around with some types to represent a game board (like Go, Chess, Scrabble, etc). I'm using a type class to represent the basic Board interface, so I can change the implementation freely: class Board b pos piece

Re: [Haskell-cafe] Re: inversion lists

2009-12-01 Thread Sjoerd Visscher
Hi Ted, Some tips: invlist_negate [] = [0] invlist_negate (0:xs) = xs invlist_negate xs = 0:xs You are doing this for generic Num instances, so 0 probably isn't the lower bound. Haskell has another type class for this: Bounded. Then you can use minBound instead of 0. Also the first line is

Re: [Haskell-cafe] Existencial Types

2009-12-01 Thread rodrigo.bonifacio
Thanks Luke. In fact I, will have different implementations of the Transformation type. Something like: data SelectScenarios = SelectScenarios { scIds :: [Id] }   And then I should be able to make SelectScenarios a kind of Transformation. So I think that I really need a class. What do you think

Re: [Haskell-cafe] Re: inversion lists

2009-12-01 Thread Daniel Peebles
You probably don't want that minBound in the pattern, but rather as a comparison in a guard. Dan On Tue, Dec 1, 2009 at 6:14 PM, Sjoerd Visscher sjo...@w3future.com wrote: Hi Ted, Some tips: invlist_negate [] = [0] invlist_negate (0:xs) = xs invlist_negate xs = 0:xs You are doing this

Re: [Haskell-cafe] Re: inversion lists

2009-12-01 Thread Daniel Fischer
Am Dienstag 01 Dezember 2009 23:31:10 schrieb Ted Zlatanov: On Fri, 20 Nov 2009 15:30:49 -0600 Ted Zlatanov t...@lifelogs.com wrote: TZ A nice property of inversion lists is that inverting them simply TZ requires removing or adding the minimum possible value at the beginning TZ of the list.

Re: [Haskell-cafe] Re: ANNOUNCE: Clutterhs 0.1

2009-12-01 Thread Iavor Diatchki
Hi On Tue, Dec 1, 2009 at 11:02 AM, Gour g...@gour-nitai.com wrote: Iavor In general, I don't think that having two similar libraries is a Iavor huge problem.  I tend to do this kind of hacking for fun, and I Iavor really do not enjoy the competition that is being encouraged Iavor when we try

Re: [Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Jeremy Fitzhardinge
On 12/01/09 15:12, Daniel Fischer wrote: Am Dienstag 01 Dezember 2009 23:34:46 schrieb Jeremy Fitzhardinge: I'm playing around with some types to represent a game board (like Go, Chess, Scrabble, etc). I'm using a type class to represent the basic Board interface, so I can change the

Re: [Haskell-cafe] Existencial Types

2009-12-01 Thread Ryan Ingram
newtype Transformation = Transformation { (+) :: SPLModel - InstanceModel - InstanceModel } data SelectScenarios = SelectScenarios { scIds :: [Id] } scenarioTransform scenario = Transformation $ \spl inst - something testScenario = SelectScenarios [] test = scenarioTransform testScenario

Re: [Haskell-cafe] Existencial Types

2009-12-01 Thread Luke Palmer
On Tue, Dec 1, 2009 at 4:21 PM, rodrigo.bonifacio rodrigo.bonifa...@uol.com.br wrote: Thanks Luke. In fact I, will have different implementations of the Transformation type. Something like: data SelectScenarios = SelectScenarios { scIds :: [Id] } What is this different type buying you?

[Haskell-cafe] seems like I'm on the wrong track

2009-12-01 Thread Michael P Mossey
Perhaps someone could either (1) help me do what I'm trying to do, or (2) show me a better way. I have a problem that is very state-ful and I keep thinking of it as OO, which is driving me crazy. Haskell is several times harder to use than Python in this instance, probably because I'm doing

Re: [Haskell-cafe] university courses on type families/GADTs?

2009-12-01 Thread Christopher Anand
I think these topics have been covered in http://www.cas.mcmaster.ca/~kahl/FP/2009/ Christopher On Tue, 1 Dec 2009 22:38:14 +0100 (CET) Tom Schrijvers tom.schrijv...@cs.kuleuven.be wrote: Hello Haskell Cafe, I was wondering whether there are any universities that teach about Haskell type

Re: [Haskell-cafe] seems like I'm on the wrong track

2009-12-01 Thread Casey Hawthorne
Please check out Paul Hudak's page. http://cs-www.cs.yale.edu/homes/hudak-paul/ On Tue, 01 Dec 2009 17:01:29 -0800, you wrote: Perhaps someone could either (1) help me do what I'm trying to do, or (2) show me a better way. I have a problem that is very state-ful and I keep thinking of it as

Re: [Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Daniel Fischer
Am Mittwoch 02 Dezember 2009 01:43:04 schrieb Jeremy Fitzhardinge: On 12/01/09 15:12, Daniel Fischer wrote: Am Dienstag 01 Dezember 2009 23:34:46 schrieb Jeremy Fitzhardinge: I'm playing around with some types to represent a game board (like Go, Chess, Scrabble, etc). I'm using a type

Re: [Haskell-cafe] seems like I'm on the wrong track

2009-12-01 Thread Michael Mossey
Thanks for the reply. Was there something specific you were referring to, or just the idea that he wrote Haskore? Haskore is not very closely related to what I'm trying to do. I believe he has a CSound back end for Haskore, but it is in a rough state and not closely related to what I'm trying

Re: [Haskell-cafe] seems like I'm on the wrong track

2009-12-01 Thread Robert Greayer
On Tue, Dec 1, 2009 at 8:01 PM, Michael P Mossey m...@alumni.caltech.eduwrote: Perhaps someone could either (1) help me do what I'm trying to do, or (2) show me a better way. I have a problem that is very state-ful and I keep thinking of it as OO, which is driving me crazy. Haskell is

Re: [Haskell-cafe] seems like I'm on the wrong track

2009-12-01 Thread Robert Greayer
On Tue, Dec 1, 2009 at 9:01 PM, Robert Greayer robgrea...@gmail.com wrote: On Tue, Dec 1, 2009 at 8:01 PM, Michael P Mossey m...@alumni.caltech.eduwrote: Perhaps someone could either (1) help me do what I'm trying to do, or (2) show me a better way. I have a problem that is very

Re: [Haskell-cafe] seems like I'm on the wrong track

2009-12-01 Thread Daniel Fischer
Am Mittwoch 02 Dezember 2009 02:01:29 schrieb Michael P Mossey: Perhaps someone could either (1) help me do what I'm trying to do, or (2) show me a better way. I have a problem that is very state-ful and I keep thinking of it as OO, which is driving me crazy. Haskell is several times harder

Re: [Haskell-cafe] seems like I'm on the wrong track

2009-12-01 Thread Michael Mossey
Daniel Fischer wrote: getNumber :: String - AssignedNumbers - (Int,AssignedNumbers) Yeah, that screams State Monad. Hi, thanks for all the advice. I was hoping my AssignedNumbers class would be useful with many data structures. In other words I would have data State1 = State1 { a ::

Re: [Haskell-cafe] seems like I'm on the wrong track

2009-12-01 Thread Daniel Fischer
Am Mittwoch 02 Dezember 2009 03:28:04 schrieb Michael Mossey: Daniel Fischer wrote: getNumber :: String - AssignedNumbers - (Int,AssignedNumbers) Yeah, that screams State Monad. Hi, thanks for all the advice. I was hoping my AssignedNumbers class would be useful with many data

Re: [Haskell-cafe] university courses on type families/GADTs?

2009-12-01 Thread Manuel M T Chakravarty
Tom Schrijvers wrote, I was wondering whether there are any universities that teach about Haskell type families or GADTs? I do in my course Language-based Software Safety (both TFs and GADTs). It's an advanced, research-oriented course for 4th year undergraduate and for postgraduate

Re: [Haskell-cafe] Trying to sort out multiparameter type classes and their instances

2009-12-01 Thread Jeremy Fitzhardinge
On 12/01/09 17:38, Daniel Fischer wrote: Am Mittwoch 02 Dezember 2009 01:43:04 schrieb Jeremy Fitzhardinge: On 12/01/09 15:12, Daniel Fischer wrote: Am Dienstag 01 Dezember 2009 23:34:46 schrieb Jeremy Fitzhardinge: I'm playing around with some types to represent a game board

Re: [Haskell-cafe] university courses on type families/GADTs?

2009-12-01 Thread Stefan Holdermans
Tom, I was wondering whether there are any universities that teach about Haskell type families or GADTs? I'm quite sure at least GADTs are covered in INFOMAFP, the graduate course on Advanced Functional Programming at UU: http://www.cs.uu.nl/docs/vakken/afp Cheers, Stefan

[Haskell-cafe] buildExpressionParser prefix recursion

2009-12-01 Thread Warren Harris
I was wondering why Parsec's buildExpressionParser doesn't allow prefix expressions to be handled recursively, e.g. given a prefix ! operation, it seems that !!a could parse without requiring parentheses (!(!a)). Is there an easy way to extend it? (I have a rich expression grammar I'd like