Re: [Haskell-cafe] type inference and named fields

2005-06-26 Thread Thomas Hallgren
Bulat Ziganshin wrote: i like O'Haskell because it's very close to traditional OO languages in its ways to extend the types. why O'Haskell is not really implemented as extension to GHC/Hugs? because it is not compatible with System F? O'Haskell *is* implemented as an extension of Hugs. Google

Re: [Haskell-cafe] type inference and named fields

2005-06-26 Thread Jonathan Cast
Daniel Brown <[EMAIL PROTECTED]> wrote: > Jonathan Cast wrote: > > Lennart Augustsson <[EMAIL PROTECTED]> wrote: > >> > >>foo :: Either a b -> Either () b > >>foo (Left _) = Left () > >>foo x@(Right _) = x > >> > >>Since Haskell type checking doesn't use the information gained by > >>pattern mat

Re: [Haskell-cafe] type inference and named fields

2005-06-26 Thread Jonathan Cast
Lennart Augustsson <[EMAIL PROTECTED]> wrote: > There are, of course, type systems where my program works fine. > O'Haskell is an example of a language with such a type system. In > O'Haskell the Either type is defined like this: > >data Left a = Left a >data Right a = Right a

Re: [Haskell-cafe] Noob error: Type b -> c b Does not match IO a

2005-06-26 Thread Henning Thielemann
On Sun, 26 Jun 2005, Daniel Fischer wrote: > >m x y = if x==0 then 0 else x*y > > Plain > > foldr m 1 > > does fine, in fact much better than > > foldl' (*) 1 . upTo (== 0), > > both in hugs and ghc, regarding speed and memory usage. E.g. foldr m 1 [a,b,c] means m a (m b (m c 1))) That

Re: [Haskell-cafe] Noob error: Type b -> c b Does not match IO a

2005-06-26 Thread Daniel Fischer
Am Sonntag, 26. Juni 2005 06:06 schrieb Scott Turner: > On 2005 June 25 Saturday 17:49, [EMAIL PROTECTED] wrote: > >Simplified: > >prodList xs = foldl (*) 1 xs > > > > But my original at least made some provision for short circuiting the > > whole operation if the list contained a 0. As fa

Re: [Haskell-cafe] Why distinct tyvars in instance declarations?

2005-06-26 Thread Henning Thielemann
On Sun, 26 Jun 2005, Daniel Fischer wrote: > Am Samstag, 25. Juni 2005 21:22 schrieb Josh Hoyt: > > Hello, > > > > I'm a new Haskeller, and I'm running into a problem attempting to > > declare certain types as instances. I was attempting something that's > > > > effectively equivalent to: > > > c

Re: [Haskell-cafe] Noob error: Type b -> c b Does not match IO a

2005-06-26 Thread Udo Stenzel
Scott Turner wrote: > It's still possible to use fold and get short circuiting with good memory > usage. > upTo pred = foldr (\a -> \xs -> if pred a then [a] else a:xs) [] > prodList = foldl' (*) 1 . upTo (== 0) > It might be considered cheating, but AFAICT the test for ==0 needs to be > se

Re: [Haskell-cafe] Why distinct tyvars in instance declarations?

2005-06-26 Thread Daniel Fischer
Am Samstag, 25. Juni 2005 21:22 schrieb Josh Hoyt: > Hello, > > I'm a new Haskeller, and I'm running into a problem attempting to > declare certain types as instances. I was attempting something that's > > effectively equivalent to: > > class Foo a > > > > instance Foo (Either b b) > > but GHC comp