Guest User

Untitled

a guest
Aug 11th, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. Why doesn't this function signature typecheck?
  2. data MyEither a b = MyLeft a | MyRight b
  3. deriving (Read, Show)
  4.  
  5. extractEither :: MyEither a b -> c
  6. extractEither (MyLeft p) = p
  7.  
  8. Couldn't match type `a' with `c'
  9. `a' is a rigid type variable bound by
  10. the type signature for extractEither :: MyEither a b -> c
  11. at /Users/tongmuchenxuan/playground/test.hs:5:1
  12. `c' is a rigid type variable bound by
  13. the type signature for extractEither :: MyEither a b -> c
  14. at /Users/tongmuchenxuan/playground/test.hs:5:1
  15. In the expression: p
  16. In an equation for `extractEither': extractEither (MyLeft p) = p
  17.  
  18. extractEither :: MyEither a a -> a
  19. extractEither (MyLeft p) = p
  20. extractEither (MyRight p) = p
  21.  
  22. extractMyLeft :: MyEither a b -> Maybe a
  23. extractMyRight :: MyEither a b -> Maybe b
  24.  
  25. extractEither :: (a -> c) -> (b -> c) -> MyEither a b -> c
  26. extractEither f g (MyLeft x) = f x
  27. extractEither f g (MyRight y) = g y
  28.  
  29. extractEither :: MyEither a b -> c
  30. extractEither (MyLeft p) = p
  31.  
  32. public Object blah(Foo whatever);
Advertisement
Add Comment
Please, Sign In to add comment