9 | data Tree a = E | T a (Tree a) (Tree a)
13 | data Trie : (Type -> Type) -> Type -> Type -> Type where
14 | MkTrie : Maybe a -> mk (Trie mk ks (Trie mk ks a)) -> Trie mk ks a
18 | {m : Type -> Type -> Type} -> {k : Type} ->
19 | FiniteMap m k => FiniteMap (Trie (m k)) (Tree k) where
20 | empty = MkTrie Nothing empty
22 | lookup E t = case t of
24 | lookup (T k a b) t = case t of
30 | bind E x t = case t of
31 | MkTrie v mk => MkTrie (Just x) mk
32 | bind (T k a b) x t = case t of
33 | MkTrie v mk => let tt = fromMaybe empty $
lookup k mk
34 | t = fromMaybe empty $
lookup a tt
37 | in MkTrie v (bind k tt' mk)