OrdKey seems pretty much tailor made for DerivingVia, and it would be possible to produce similar newtypes for tries implemented using IntMap, HashMap, etc. However, it's not actually possible to use DerivingVia to derive TrieKey. Ugh. The problem is the usual one of traversals. Since we control the types of the internals, we can work around that in a somewhat well known but rarely used way:
trieTraverse :: (Applicative f, Coercible (Trie k b) r) => (a -> f b) -> Trie k a -> f r
gtrieTraverse :: (Applicative m, Coercible (GTrie f b) r) => (a -> m b) -> GTrie f a -> m r
With these method types, and similar ones for trieTraverseWithKey, trieTraverseMaybeWithKey, etc., we should be able to unlock the convenience for users.
OrdKey
seems pretty much tailor made forDerivingVia
, and it would be possible to produce similar newtypes for tries implemented usingIntMap
,HashMap
, etc. However, it's not actually possible to useDerivingVia
to deriveTrieKey
. Ugh. The problem is the usual one of traversals. Since we control the types of the internals, we can work around that in a somewhat well known but rarely used way:With these method types, and similar ones for
trieTraverseWithKey
,trieTraverseMaybeWithKey
, etc., we should be able to unlock the convenience for users.