Skip to content

Instantly share code, notes, and snippets.

@Abhiroop
Last active October 30, 2017 11:54
Show Gist options
  • Save Abhiroop/44d49bb895ad6aeb34f987ff23caef50 to your computer and use it in GitHub Desktop.
Save Abhiroop/44d49bb895ad6aeb34f987ff23caef50 to your computer and use it in GitHub Desktop.
data Nat = Zero | Succ Nat
data T n a = NodeR (Tree n a) a (Tree (Succ n) a) -- right subtree has height + 1
| NodeL (Tree (Succ n) a) a (Tree n a) -- left subtree has height + 1
| Node (Tree n a) a (Tree n a) -- both subtrees are of equal height
data Tree n a where
Branch :: T n a -> Tree (Succ n) a
Leaf :: Tree Zero a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment