Reputation: 109
When I type this code in Haskell:
data BT a = Empty | Fork a (BT a) (BT a)
Empty :: BT a
Fork :: a -> BT a -> BT a -> BT a
I get
error: parse error on input `::'
I can't see what the issue is though, if I add deriving (show)
to the top line, it changes to
error: parse error on input `Empty'
Upvotes: 0
Views: 95
Reputation: 7014
Either write it using the "legacy" uniform datatype syntax:
data BT a = Empty | Fork a (BT a) (BT a)
or use equivalent GADT syntax
{-# Language GADTs #-}
data BT a where
Empty :: BT a
Fork :: a -> BT a -> BT a -> BT a
But not both :)
Upvotes: 6