Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This is a utility module that consolidates all Context
-related operations
Context
A (Context a)
associates Text
labels with values of type a
.
Each Text
label can correspond to multiple values of type a
The Context
is used for type-checking when (a = Expr X)
- You create a
Context
usingempty
andinsert
- You transform a
Context
usingfmap
- You consume a
Context
usinglookup
andtoList
The difference between a Context
and a Map
is that a Context
lets you have multiple ordered occurrences of the same key and you can
query for the n
th occurrence of a given key.
match :: Context a -> Maybe (Text, a, Context a) Source #
"Pattern match" on a Context
match (insert k v ctx) = Just (k, v, ctx) match empty = Nothing