Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
data NMap :: [Mapping Symbol Type] -> Type where Source #
A depedently-typed product, or map. The following are roughly equivalent:
type A = NMap '[ "a" ':-> Int, "b" ':-> Bool ] data A = A { a :: Int, b :: Bool }
unionMap :: forall xs ys. (SingI xs, SingI ys) => (NMap xs, NMap ys) -> NMap (Union xs ys) Source #
Combine two NMap
s in a way such that the original ordering of
their fields doesn't matter; no matter how you combine smaller maps
to create a large one, you are guaranteed to have a sorted NMap
when you finish.
NMap
s form a commutative monoid under unionMap
, with
NMapEmpty
as the identity.
This function takes a tuple as an argument so that it is symmetric
with ununionMap
.
ununionMap :: forall xs ys. (SingI xs, SingI ys) => NMap (Union xs ys) -> (NMap xs, NMap ys) Source #
Split a sorted NMap
into two arbitrary (and potentially
unsorted) submaps. Conveniently select the submaps to split into
using -XTypeApplications
.
>>>
m :: NMap '[ "a" ':-> Int, "b" ':-> Bool, "c" ':-> String ]
>>>
m = NMapExt 1 (NMapExt True (NMapExt "hello" NMapEmpty))
>>>
ununionMap @'[ "b" ':-> Bool, "a" ':-> Int ] @'[ "c" ':-> String ] m
({ b :-> True, a :-> 1 },{ c :-> "hello" })
module Data.NamedSOP.Type