glguy / tries

BSD 3-Clause "New" or "Revised" License
11 stars 8 forks source link

Add instances for arrays and maybe vectors #15

Open treeowl opened 4 years ago

treeowl commented 4 years ago

Small arrays, at least, seem like reasonable things to use as trie keys.

strake commented 4 years ago

Would it make sense to define such as the following?:

newtype FoldableKey f a = FoldableKey (f a)

instance (TrieKey a, Foldable f) => TreeKey (FoldableKey f a) where
    {- methods defined in terms of `toList` -}
treeowl commented 1 year ago

@strake, no, it wouldn't. These tries need to be able to rebuild keys from their paths. I wouldn't be surprised if it were just barely possible to do it with Traversable, but I'd be very surprised if that could be made efficient.

treeowl commented 1 year ago

Let me take that back. It's probably possible to do something with Foldable, storing the key alongside the value. It just doesn't match the rest of what goes on here.