Closed sgraf812 closed 2 years ago
Ah, nevermind. I obviously forgot the instance TrieKey
declarations. If I add
instance TrieKey a => TrieKey (Fork a) where
instance TrieKey a => TrieKey (Perfect a) where
bar :: Trie (Perfect Int) Int
bar = singleton (Succ (Succ (Zero (Fork (Fork 1 2) (Fork 3 4))))) 42
it works. But empty :: Trie (Perfect a) Int
will only work with a TrieKey a
constraint. Anyway, will close this again.
I'm currently following Generalizing Generalized Tries (there's also a slightly different publicly available version here) which describes derivation of tries for nested data structures such as
Perfect
below (note the nested recursion forFork a
) as quite challenging. Out of curiosity, I tried the following codeAnd it errors out with
Which I think is reasonable if it was properly documented.