Re: [Haskell-cafe] Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-26 Thread Daniel Fischer
Extremely odd, today ghc 6.4.2 (also on linux) works for me, too: Prelude InfixR> show (A `And` A) "A `And` A" Prelude InfixR> show (And A A) "A `And` A" Prelude InfixR> read (show (And A A)) :: T A `And` A Prelude InfixR> read "And A A" :: T *** Exception: Prelude.read: no parse Prelude InfixR> r

[Haskell-cafe] Re: [Haskell] Exists any null instruction in Haskell?

2006-08-26 Thread Neil Mitchell
[Moving to haskell-cafe] Hi, I want to know if it exists a null instruction (a instruction that do anything Not really, since instructions don't "do anything" anyway - they only compute values. If you are in the IO monad then "return ()" is the do nothing. In the function world, "id" is the

Re: [Haskell-cafe] Re: Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-26 Thread Misha Aizatulin
Ian Lynagh wrote: > ghci on 6.4.2 Linux works for me: oops, works for me too - I forgot the type annotation when calling read :) So it's fine in 6.4.2 - sorry for the disturbance then! Cheers, Misha ___ Haskell-Cafe mailing list Haskell-Cafe@haske

Re: [Haskell-cafe] Re: Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-26 Thread Misha Aizatulin
Jason Dagit wrote: > Before you get too caught up in deriving Read, remember that in > Haskell it's very easy to create your own custom parser. Assuming you > have previous experience with happy or parsec you could probably have > already created a custom parser with time you've spent debugging t

[Haskell-cafe] OOP vs type classes: Everything is object?

2006-08-26 Thread Bulat Ziganshin
Hello haskell-cafe, i've added section http://haskell.org/haskellwiki/OOP_vs_type_classes#Everything_is_object.3F which lists cases when we DON'T use type classes to emulate OOP classes features -- Best regards, Bulat mailto:[EMAIL PROTECTED] __

Re: [Haskell-cafe] Re: Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-26 Thread Ian Lynagh
On Sat, Aug 26, 2006 at 10:15:17PM +0300, Misha Aizatulin wrote: > Neil Mitchell wrote: > >> *Main> show $ A `And` A > >> "A And A" > > > > For me, using GHCi 6.4.2 + Windows, I get: > > "A `And` A" > > I installed GHC 6.4.2 now (on Linux). It really does print "A `And` > A", but still doesn't

Re: [Haskell-cafe] Re: Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-26 Thread Jason Dagit
On 8/26/06, Misha Aizatulin <[EMAIL PROTECTED]> wrote: Neil Mitchell wrote: >> *Main> show $ A `And` A >> "A And A" > > For me, using GHCi 6.4.2 + Windows, I get: > "A `And` A" I installed GHC 6.4.2 now (on Linux). It really does print "A `And` A", but still doesn't read it. Would you agree th

[Haskell-cafe] Re: Derived Read instance for types with infix constructors (ghc 6.4.1)

2006-08-26 Thread Misha Aizatulin
Neil Mitchell wrote: >> *Main> show $ A `And` A >> "A And A" > > For me, using GHCi 6.4.2 + Windows, I get: > "A `And` A" I installed GHC 6.4.2 now (on Linux). It really does print "A `And` A", but still doesn't read it. Would you agree that GHC doesn't conform to the Haskell Report here? In fa

Re: [Haskell-cafe] monads once again: a newbie perspective

2006-08-26 Thread Lennart Augustsson
I like sigfpe's introduction to monads: http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads- and.html -- Lennart On Aug 26, 2006, at 14:04 , Andrea Rossato wrote: Il Fri, Aug 25, 2006 at 01:13:58PM -0400, Cale Gibbard ebbe a scrivere: Hey cool, a new monad tutorial!

Re: [Haskell-cafe] monads once again: a newbie perspective

2006-08-26 Thread Andrea Rossato
Il Fri, Aug 25, 2006 at 01:13:58PM -0400, Cale Gibbard ebbe a scrivere: > Hey cool, a new monad tutorial! :) > > Just out of interest, have you seen my Monads as Containers article? > http://www.haskell.org/haskellwiki/Monads_as_Containers > > Let me know what you think of it. I find that often n

Re[2]: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Bulat Ziganshin
Hello Andrea, Saturday, August 26, 2006, 6:40:06 PM, you wrote: >> Of course, newtype can also be used to define type whose only field >> contains some function: >> >> newtype F = F (String->Int) >> >> Again, in this case language guarantees that internal F representation >> will be the same as

Re: [Haskell-cafe] Space leak whilst implementing streams

2006-08-26 Thread Udo Stenzel
[EMAIL PROTECTED] wrote: > I found a way to remove this space leak, however, I do not really > understand why there was a space leak in the first place. I would > really appreciate any light that could be shed on this. > instance ArrowChoice SF where > left (SF f) > = SF (\xs -> combine xs

Re: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Andrea Rossato
Il Sat, Aug 26, 2006 at 06:00:02PM +0400, Bulat Ziganshin ebbe a scrivere: > type HashFunction = (String->Int) ... > createHash :: HashFunction -> IO Hash > and > createHash :: (String->Int) -> IO Hash > > are equivalent. So, technically speaking, you can't declare function > types, there is only

Re: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Udo Stenzel
Andrea Rossato wrote: > this is what I'm trying to do, sort of: turn the code at the button > into the do-notation.[1] > type MSO a = State -> (a, State, Output) > > mkMSO :: a -> MSO a > mkMSO a = \s -> (a, s, "") > > bindMSO :: MSO a -> (a -> MSO b) -> MSO b > bindMSO m f = \x -> >

Re: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Andrea Rossato
Il Sat, Aug 26, 2006 at 02:25:51PM +0100, Brian Hulley ebbe a scrivere: > runMSO :: MSO a -> State -> (a, State, Output) > runMSO (MSO f) s = f s this is exactly what I was looking for runMSO (MSO f) s = f s I've already done the previous part, but I was running it as: runMSO a = evalMSO a 0

Re[2]: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Bulat Ziganshin
Hello Andrea, Saturday, August 26, 2006, 1:44:19 PM, you wrote: >> perhaps this is silly, but it is not possible to declare function >> types? >> >> could you please indicate me some documentation that explains this >> kind of stuff? So far I didn't find anything on that. > well, I've found som

Re: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Brian Hulley
Andrea Rossato wrote: this is what I'm trying to do, sort of: turn the code at the button into the do-notation.[1] module StateOutputMonad where -- do notation only works with instances of Monad import Control.Monad data Term = Con Int | Add Term Term deriving (Show) typ

[Haskell-cafe] Space leak whilst implementing streams

2006-08-26 Thread ephemeral . elusive
Hello, I have been using arrows to implement stream processors. At first, I tried using the implementation presented in John Hughes' AFP arrows lectures. However, this appeared to have a space leak in its implementation of the left operator for ArrowChoice. I found a way to remove this space lea

Re: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Andrea Rossato
Il Sat, Aug 26, 2006 at 11:55:34AM +0100, Brian Hulley ebbe a scrivere: > Yes, it's useful because it allows you to make a distinction between > different uses of the same type of function and make these different uses > into instances of different classes. It also allows you to hide the fact >

Re: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Brian Hulley
Brian Hulley wrote: I recommend chapter 8 of "Yet another Haskell Tutorial" which can be downloaded from http://www.haskell.org/haskellwiki/Books_and_tutorials#.E2.80.9CReal_world.E2.80.9D_tutorials Sorry - the correct part of the wiki page is: http://www.haskell.org/haskellwiki/Books_and_tuto

Re: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Brian Hulley
Andrea Rossato wrote: Il Sat, Aug 26, 2006 at 01:27:38AM +0200, Daniel Fischer ebbe a scrivere: Because T a is a function type, namely Int -> (a,Int), so ... iHowever, neither T1 a nor T2 a is a function type, a value of type T1 a is a function _wrapped by the data (or value) constructor T1_

Re: [Haskell-cafe] difference between type and newtype

2006-08-26 Thread Andrea Rossato
Il Sat, Aug 26, 2006 at 02:02:36AM +0200, Andrea Rossato ebbe a scrivere: > perhaps this is silly, but it is not possible to declare function > types? > > could you please indicate me some documentation that explains this > kind of stuff? So far I didn't find anything on that. well, I've found so