(no title)
nyssos | 1 year ago
Here's an implementation using GADTs and type-level addition
data Node (level :: Nat) (a :: Type) where
Leaf :: a -> Node Zero a
Interior :: a -> (Node l a, Node l a) -> Node (l + 1) a
It's impossible to construct an unbalanced node, since `Interior` only takes two nodes of the same level, and every `Leaf` is of level 0.
No comments yet.