Skip to content

Instantly share code, notes, and snippets.

@amiller
Created August 27, 2012 05:00
Show Gist options
  • Save amiller/3485737 to your computer and use it in GitHub Desktop.
Save amiller/3485737 to your computer and use it in GitHub Desktop.
data Trunk m x = Tip | Bin (m x) (m x)
instance (Monad m) => Functor (Trunk m) where
fmap f (Bin x y) = Bin (x >>= return . f) (y >>= return . f)
fmap _ Tip = Tip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment