
Hi, 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? Thanks in advance. Kind regards

Am Samstag 25 April 2009 19:29:30 schrieb siso dagbovie:
Hi,
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? Thanks in advance.
A constructor symbol has to start with a colon, so make it data Graph a b = Empty | Context a b :& Graph a b (or :&: if you prefer it more symmetric)
Kind regards
Cheers, Daniel

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@functor.nl GPG: 0xE6FABFAB
participants (3)
-
Daniel Fischer
-
Jochem Berndsen
-
siso dagbovie