Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@berewt
Created January 9, 2017 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berewt/493917aa861206cb2be871bf5bc15a26 to your computer and use it in GitHub Desktop.
Save berewt/493917aa861206cb2be871bf5bc15a26 to your computer and use it in GitHub Desktop.
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