Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. instance Num a => Num (Tree a) where
  2. (+) (Leaf _) x = x
  3. (+) (Branch l r) x = Branch (l+x) r
  4. (*) (Leaf a) (Leaf b) = Leaf (a + b)
  5. (*) (Branch l1 r1) (Branch l2 r2) = Branch (l1*l2) (r1*r2)
  6. (*) _ _ = error "Undefined"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement