[Haskell-beginners] Odd behavior from WinHugs
Daniel Fischer
daniel.is.fischer at web.de
Wed Jan 14 16:07:06 EST 2009
Am Mittwoch, 14. Januar 2009 21:23 schrieb Conrad Meyer:
> On Wednesday 14 January 2009 11:46:23 am Justin Bailey wrote:
> > You have to capitalize your type names and data constructors:
> >
> > data MyTuple a b c d = My4Tuple a b c d
> >
> > | My3Tuple a b c
> > | My2Tuple a b
> > | My1Tuple a
> >
> > deriving (Show)
>
> Also, I think (but by no means am I sure) that you should cut out 'a b c d'
> from the left side, i.e.:
>
> data MyTuple = My4Tuple a b c d
>
> | My3Tuple a b c
> | My2Tuple a b
> | My1Tuple a
>
> deriving (Show)
>
> Someone please tell me if I am wrong :).
The type variables are necessary on the left hand side, otherwise a
(My3Tuple x y z) could hold values of completely unknown type and so you
couldn't do anything useful with it.
If the types of things held weren't specified on the left, what type could
firstOfTuple have?
>
> Regards,
More information about the Beginners
mailing list