[Haskell-cafe] parse error on input `&'

Jochem Berndsen jochem at functor.nl
Sat Apr 25 13:51:36 EDT 2009


siso dagbovie wrote:
> I've defined the following datatype with haskell
>
> data Graph a b = Empty | Context a b & Graph a b
>
> But I am having the error message: " parse error on input `&'  ".
> I am wondering what it is wrong with my definition. How can I fix this?

Constructors have to start with a capital or a : (colon).
So changing your definition into
data Graph a b = Empty | Context a b :& Graph a b
will work.

If you want you can define
(&) = (:&)
and use the & symbol for constructing graphs (not in pattern matches
though).

HTH,

-- 
Jochem Berndsen | jochem at functor.nl
GPG: 0xE6FABFAB


More information about the Haskell-Cafe mailing list