module UHC.Util.CHR.Key
(
TTKeyableOpts(..)
, defaultTTKeyableOpts
, TTKeyable(..)
, TTKey
, toTTKey
)
where
import UHC.Util.TreeTrie
data TTKeyableOpts
= TTKeyableOpts
{ ttkoptsVarsAsWild :: Bool
}
defaultTTKeyableOpts = TTKeyableOpts True
type family TTKey x :: *
type instance TTKey [x] = TTKey x
type instance TTKey (Maybe x) = TTKey x
class TTKeyable x where
toTTKey' :: TTKeyableOpts -> x -> TreeTrieKey (TTKey x)
toTTKeyParentChildren' :: TTKeyableOpts -> x -> (TreeTrie1Key (TTKey x), [TreeTrieMpKey (TTKey x)])
toTTKey' o = uncurry ttkAdd' . toTTKeyParentChildren' o
toTTKeyParentChildren' o = ttkParentChildren . toTTKey' o
toTTKey :: (TTKeyable x, TTKey x ~ TrTrKey x) => x -> TreeTrieKey (TTKey x)
toTTKey = toTTKey' defaultTTKeyableOpts