glguy / tries

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

Function to fold / map / traverse split keys #3

Closed adamflott closed 7 years ago

adamflott commented 7 years ago

[ Feel free to close if this breaks the spirit of generic-trie ]

I'd like functions to walk the split keys and potential value (as opposed to foldWithkey which operates on the full key). My goal is to leverage the Data.GenericTrie work to convert the in memory trie into a suitable JSON representation for my data type.

glguy commented 7 years ago

Do you have an example input and output you had in mind for how this would look?

adamflott commented 7 years ago

Given "/a/b/c" -> [1,2] , "/a/b/d" -> [3, 4] as keys, values, I'd like to have a function that would give

  1. "a"
  2. "b"
  3. "c", [1,2]
  4. "d", [3,4]

Ultimately I'm after making the ToJSON instances easy to write.

glguy commented 7 years ago

This type isn't really going to be able to support this operation

adamflott commented 7 years ago

Bummer.