for more information visit the package's GitHub page
Package contains the following modules:
Simple layers over the standard Elm containers (Dict and Set), that allow more types of keys than just 'comparable'. When you create the TDict or TSet, you must supply conversion functions to go from your key types to 'comparable' and back.
This gives you a little extra type safety, at the cost of a little extra hassle.
Herer's an example where you have types that are really just comparables underneath, but you want to keep them segregated for safety:
-- both types are floats, but we don't want to mix the
-- values together accidentally.
type Kilos =
Kilos Float
type Pounds =
Pounds Float
-- Create a TSet with the empty function, which takes two
-- conversion functions as arguments. It can be convenient
-- to create a canonical empty TSet for a certain type:
emptyKiloSet =
TSet.empty
(\(Kilos n) -> n)
Kilos
-- a list of Kilo values.
kilolist = [Kilo 1.0, Kilo 2.0]
-- Then to do the equivalent of fromList:
kiloSet = TSet.insertList emptyKiloSet kilolist
-- but you can't put the kilolist into a pounds Set.
emptyPoundSet =
TSet.empty
(\(Pounds n) -> n)
Pounds
TSet.insertList emptyPoundSet kilolist -- type error!