Created
January 9, 2017 07:19
-
-
Save berewt/493917aa861206cb2be871bf5bc15a26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module NodeLeafTree where | |
import Data.Bifunctor | |
import Data.List.NonEmpty | |
data Tree a b | |
= Leaf a | |
| Node b (NonEmpty (Tree a b)) | |
instance Bifunctor Tree where | |
bimap f g (Leaf x) = f x | |
bimap f g (Node x ys) = Node (f x) (fmap (bimap f g) ys) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment