Copyright | Flipstone Technology Partners 2023 |
---|---|
License | MIT |
Stability | Stable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Since: 1.0.0.0
Synopsis
- data Many k a
- data NotAKey = NotAKey
- fromKeys :: [k] -> (k -> Either NotAKey a) -> Many k a
- lookup :: k -> Many k a -> Either NotAKey a
- keys :: Many k a -> [k]
- elems :: Many k a -> [a]
- map :: (a -> b) -> Many k a -> Many k b
- toMap :: Ord k => Many k a -> Map k a
- apply :: Many param (a -> b) -> Many param a -> Many param b
- compose :: Many b c -> Many a b -> Many a c
Documentation
A 'Many k a' represents a group of values keyed by list of parameters and
is used to return the results of executing an Orville Plan with a list of
input parameters. If you need to find the result of the query associated
with a particular input parameter, you can use lookup
to find it. If you
don't care about the association with particular inputs, you can simply
use elems
to get a list of all the results.
Since: 1.0.0.0
fromKeys :: [k] -> (k -> Either NotAKey a) -> Many k a Source #
fromKeys
constructs a Many
value from a list of keys and a function that
maps them to their values. The order and duplication of keys in the list will
be preserved by the Many
type in the relevant functions. The mapping
function provided should be a total function -- i.e. it should not produce a
runtime error. If it is not possible to map every k
(even those not in the
input list provided to fromKeys
), the values should be wrapped in an
appropriate type such as Maybe
so that an empty or default value can be
returned.
Since: 1.0.0.0
lookup :: k -> Many k a -> Either NotAKey a Source #
lookup
returns the value for the given parameter. If the given k
is
not one of the original input values that the Many
was constructed with,
the mapping function given at the contructor will determine what value to
return. Often this will be whatever a reasonable empty or default value for
the type a
is.
Since: 1.0.0.0
apply :: Many param (a -> b) -> Many param a -> Many param b Source #
apply
allows you to apply many functions to many values. The function
associated with each parameter is applied to the value associated with the
same paremeter.
(If you're looking for pure
or an Applicative
instance
for Many
, this is as good as it gets. Many
cannot be an
Applicative
because there is no correct implementation of
pure
that we can reasonably provide).
Since: 1.0.0.0