[Haskell-beginners] Questions on data/type

Jason Dusek jason.dusek at gmail.com
Tue Nov 17 01:11:32 EST 2009

2009/11/15 Matthew Wong <matwong at rogers.com>:
> If I want to express the following idea (the following won't compiler):
> data TypeCon a = ValConA a | ValConB [ValConA a] | ValConC [ValConB a]

  In this definition, you are confusing constructors with types.
  You can't have a list of `ValConB a` -- the type is actually
  `TypeCon a`.

> The alternative is use 3 different type constructors,
> data TypeConA a = ValConA a
> data TypeConB a = ValConB a
> data TypeConC a = ValConC a

  This is more promising. I'd need to see the typeclass you're
  trying to define to say more.

Jason Dusek

More information about the Beginners mailing list