Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. data Matter = Solid | Liquid | Gas
  2.  
  3. interface MyEq ty where
  4. (==) : ty -> ty -> Bool
  5. (/=) : ty -> ty -> Bool
  6.  
  7. MyEq Matter where
  8. (==) Solid Solid = True
  9. (==) Liquid Liquid = True
  10. (==) Gas Gas = True
  11. (==) _ _ = False
  12.  
  13. (/=) x y = not (x == y)
  14.  
  15. occurrences : MyEq ty => (item :ty) -> (values : List ty) -> Nat
  16. occurrences item [] = 0
  17. occurrences item (value :: values) = case value == item of
  18. False => occurrences item values
  19. True => 1 + occurrences item values
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement