Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data JoinList m a = Empty
- | Single m a
- | Append m (JoinList m a) (JoinList m a)
- deriving (Eq, Show)
- tag :: Monoid m => JoinList m a -> m
- tag Empty = mempty
- tag (Single x _) = x
- tag (Append x left right) = x
- *JoinList Data.Monoid> tag (Append (Product 100) (Single (Product 10) "foo") (Single (Product 10) "bar"))
- Product {getProduct = 100}
- *JoinList Data.Monoid> tag (Empty :: JoinList (Product Integer) String)
- Product {getProduct = 1}
- *JoinList Data.Monoid> tag (Single (Product 5) "foo")
- Product {getProduct = 5}
- tag (Append x left right) = x `mappend` (tag left) `mappend` (tag right)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement