freckle / bcp47

BCP-47 for Haskell
https://freckle.github.io/bcp47/
2 stars 1 forks source link

Add Trie data structure #1

Closed eborden closed 5 years ago

eborden commented 5 years ago

Variations of a single piece of content can be stored within a Trie data structure to enable finding applicable versions of the content. The Trie maps the components of the language tag in a path. Like a bitmapped Trie or a string Trie each branch of the tree can also contain an element.

The find operation allows the most specific version of a given piece of content to be found within the Trie.

An exact match

  let trie = fromList [(enGBTJP, "foo"), (enGB, "colour")]
  find enGBTJP trie `shouldBe` Just "foo"

Or just a relevant match

  let trie = fromList [(en, "color"), (enGB, "colour")]
  find enTJP trie `shouldBe` Just "color"