
Untitled
By: a guest on
Aug 11th, 2012 | syntax:
None | size: 1.04 KB | hits: 7 | expires: Never
Why doesn't this function signature typecheck?
data MyEither a b = MyLeft a | MyRight b
deriving (Read, Show)
extractEither :: MyEither a b -> c
extractEither (MyLeft p) = p
Couldn't match type `a' with `c'
`a' is a rigid type variable bound by
the type signature for extractEither :: MyEither a b -> c
at /Users/tongmuchenxuan/playground/test.hs:5:1
`c' is a rigid type variable bound by
the type signature for extractEither :: MyEither a b -> c
at /Users/tongmuchenxuan/playground/test.hs:5:1
In the expression: p
In an equation for `extractEither': extractEither (MyLeft p) = p
extractEither :: MyEither a a -> a
extractEither (MyLeft p) = p
extractEither (MyRight p) = p
extractMyLeft :: MyEither a b -> Maybe a
extractMyRight :: MyEither a b -> Maybe b
extractEither :: (a -> c) -> (b -> c) -> MyEither a b -> c
extractEither f g (MyLeft x) = f x
extractEither f g (MyRight y) = g y
extractEither :: MyEither a b -> c
extractEither (MyLeft p) = p
public Object blah(Foo whatever);