Advertisement
Guest User

Clean

a guest
Nov 26th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. class Foldable t
  2. where
  3. fold :: (a b -> b) b (t a) -> b
  4.  
  5. instance Foldable []
  6. where
  7. fold :: (a b -> b) b [a] -> b
  8. fold op r l = foldr op r l
  9.  
  10. instance Foldable Tree
  11. where
  12. fold :: (a b -> b) b (Tree a) -> b
  13. fold op r Empty = r
  14. fold op r (Node a b c) = fold op (fold op (op b r) a) c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement