On Thu, Jul 23, 2009 at 08:17:34PM +0100, Iain Barnett wrote:
> [..]
> against the empty list it's not really a problem to have it there. I didn't
> realise I could use Maybe in the constructor because it's a monad, but
> that's good because I was wondering about the best way to make a nullable
> value.

Actually, this has nothing to do with Maybe being a monad. The reason
you can do this is because "Maybe" itself is not a type, but a (unary)
type constructor(It has kind * -> *), so you need to apply it to
another type. Doing something like "test :: Maybe" would be an error.

> That Data.Tree module looks interesting too! It does seem to be a
> naturally recursive type, but I'm still trying to become easy with that sort
> of thought :)
> [..]

A list is also recursively defined, so it is not really more difficult
to use a Tree instead. E.g. one could define a list type like this:
 data List a = Nil | Cons a (List a)

- Daniel

Attachment: pgpx25fhhGIwn.pgp
Description: PGP signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to