[Haskell] Signature error because the order

2010-01-14 Thread Luis Cabellos
Hi,

  I found than this piece of code causes an error in GHC ( *
http://haskell.pastebin.com/m5e3f4a4c* ):

data Tree a = Leaf a | Node (Tree a) (Tree a)

--prettyShow :: (Show a, Num a) => Tree a -> String  -- WORKS
prettyShow :: (Num a, Show a) => Tree a -> String  -- FAILS
prettyShow (Leaf a) = show a
prettyShow (Node a b) = (simple a) ++ (simple b)

simple :: (Show a, Num a) => Tree a -> String
simple (Leaf x) = prettyShow (Leaf x)
simple x = "(" ++ prettyShow x ++ ")"

With the error:
test.lhs:14:0:
Couldn't match expected type `Show a'
   against inferred type `Num a1'
When matching the contexts of the signatures for
  prettyShow :: forall a. (Num a, Show a) => Tree a -> String
  simple :: forall a. (Show a, Num a) => Tree a -> String
The signature contexts in a mutually recursive group should all be
identical
When generalising the type(s) for prettyShow, simple
Failed, modules loaded: none.


But if I change the order of *Show* and *Num* in the signature of *
prettyShow* it works.

It's a GHC problem? it's normal than signature is order-dependent?

I use *GHC  6.10.3*

Thanks, Luis Cabellos

-- 

LC, ("There is no Dana, only Zuul." - Cazafantasmas [1984])
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] getting started

2011-09-28 Thread Luis Cabellos
On Wed, Sep 28, 2011 at 11:56 AM, haskell wrote:

> i am new to haskell can you tell me the softwares to install in haskell
> i have install hugs emacs
> but when i write any code it gives same error can you help me start i have
> lekash too i have installed some more packages
>
> As Ivan recommended, use Haskell Platform:

You can try to learn using this:
http://www.haskell.org/haskellwiki/How_to_write_a_Haskell_program

You will learn the good practices from the very beginning.

Next, read "Real World Haskell". Free online, not so free Amazon.
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell