orville-postgresql-1.0.0.0: A Haskell library for PostgreSQL
CopyrightFlipstone Technology Partners 2023
LicenseMIT
StabilityStable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Orville.PostgreSQL.Plan.Many

Description

Since: 1.0.0.0

Synopsis

Documentation

data Many k a Source #

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

Instances

Instances details
Functor (Many k) Source # 
Instance details

Defined in Orville.PostgreSQL.Plan.Many

Methods

fmap :: (a -> b) -> Many k a -> Many k b #

(<$) :: a -> Many k b -> Many k a #

data NotAKey Source #

NotAKey is returned from various Many related functions when presented with an input parameter that was not one of the original inputs that the Many was constructed with.

Since: 1.0.0.0

Constructors

NotAKey 

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

keys :: Many k a -> [k] Source #

keys fetches the list of keys from a Many. Note that is a list and not a set. Many preserves the order and duplication of any key values that were in the key list at the time of construction.

Since: 1.0.0.0

elems :: Many k a -> [a] Source #

elems returns all the values that correspond to the keys of the Many. The values will be returned in the same order that the keys were present at the time of creation, though if you truly care about this it's probably better to use lookup to make that correspondence explicit.

Since: 1.0.0.0

map :: (a -> b) -> Many k a -> Many k b Source #

map calls a function on all the values found in a Many collection.

Since: 1.0.0.0

toMap :: Ord k => Many k a -> Map k a Source #

toMap converts the Many into a Map value. If all you wanted to do was find the value for a specific key, you should probably use lookup instead.

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

compose :: Many b c -> Many a b -> Many a c Source #

compose uses the values of a Many value as keys to a second Many to create a Many mapping from the original keys to the final values.

Since: 1.0.0.0