Last active
September 1, 2017 16:23
-
-
Save hrb90/99d50d1416e5b93436f23981814ba77b to your computer and use it in GitHub Desktop.
i is a haskell programmer
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
{-# LANGUAGE DeriveFunctor #-} | |
data MaybePair a = Pair (Maybe a) (Maybe a) | |
deriving (Eq, Show, Functor) | |
data BinaryTree a = | |
Node a (MaybePair (BinaryTree a)) | |
deriving (Eq, Show) | |
invert :: BinaryTree a -> BinaryTree a | |
invert (Node x children) = Node x $ invertPair $ invert <$> children | |
where invertPair (Pair left right) = Pair right left |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment