Intro to Functional Prog. by Bird, Section 2.5
Shawn P. Garbett
listman@garbett.org
Wed, 2 Jan 2002 08:55:34 -0600
I've been working on understanding Haskell using hugs98 and playing with some
of the examples in Bird's book.
In section 2.5, page 46 of the second edition, he gives an example of
dependent types:
But I get this error I've been unable to solve:
----------------------------------------------------------------------------------------------------------------
--Type checking
--ERROR sec2-5.hs:8 - Type error in application
--*** Expression : case' (Left' f,Right' g)
--*** Term : (Left' f,Right' g)
--*** Type : (Either' (d -> e) f,Either' g (h -> i))
--*** Does not match : (a -> b,c -> b)
data Either' a b = Left' a | Right' b
case' :: (a->g, b->g) -> Either' a b -> g
case' (f, g) (Left' x) = f x
case' (f, g) (Right' y) = g y
plus' :: (a->b , g->d) -> Either' a g -> Either' b d
plus' (f,g) = case' (Left' f, Right' g)
-----------------------------------------------------------------------------
Please note that the version I've entered is correct by the errata published
for this section.