Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- ptryLookup :: forall (k :: PType) (v :: PType) (keys :: KeyGuarantees) (s :: S). (PIsData k, PIsData v) => Term s (k :--> (PMap keys k v :--> v))
- pkeysEqual :: forall (k :: PType) (a :: PType) (b :: PType) (s :: S). (PIsData k, PEq k) => Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool))
- pkeysEqualUnsorted :: forall (k :: PType) (a :: PType) (b :: PType) (s :: S). (PIsData k, PIsData a, PIsData b) => Term s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
- pupdate :: forall (k :: PType) (v :: PType) (s :: S). (PIsData k, PIsData v, POrd k) => Term s ((v :--> PMaybe v) :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v)))
- padjust :: forall (k :: PType) (v :: PType) (s :: S). (PIsData k, PEq k, PIsData v) => Term s ((v :--> v) :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v)))
- pmapWithKey :: forall (k :: PType) (a :: PType) (b :: PType) (keysort :: KeyGuarantees) (s :: S). (PIsData k, PIsData a, PIsData b) => Term s ((k :--> (a :--> b)) :--> (PMap keysort k a :--> PMap 'Unsorted k b))
- pfoldMapWithKey :: forall (m :: PType) (k :: PType) (v :: PType) (s :: S). (PIsData k, PIsData v, forall (s' :: S). Monoid (Term s' m)) => Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m))
- pfoldlWithKey :: forall (a :: PType) (k :: PType) (v :: PType) (s :: S). (PIsData k, PIsData v) => Term s ((a :--> (k :--> (v :--> a))) :--> (a :--> (PMap 'Sorted k v :--> a)))
- pkeys :: forall (ell :: PType -> PType) (k :: PType) (v :: PType) (keys :: KeyGuarantees) (s :: S). (PListLike ell, PElemConstraint ell (PAsData k)) => Term s (PMap keys k v :--> ell (PAsData k))
- pkvPairKey :: forall (k :: PType) (v :: PType) (s :: S). PIsData k => Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k)
- pkvPairValue :: forall (k :: PType) (v :: PType) (s :: S). PIsData v => Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v)
- pkvPairLt :: forall (k :: PType) (v :: PType) (s :: S). (PIsData k, PPartialOrd k) => Term s (PBuiltinPair (PAsData k) (PAsData v) :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool))
Lookup
ptryLookup :: forall (k :: PType) (v :: PType) (keys :: KeyGuarantees) (s :: S). (PIsData k, PIsData v) => Term s (k :--> (PMap keys k v :--> v)) Source #
As plookup
, but errors when the key is missing.
Comparisons
pkeysEqual :: forall (k :: PType) (a :: PType) (b :: PType) (s :: S). (PIsData k, PEq k) => Term s (PMap 'Sorted k a :--> (PMap 'Sorted k b :--> PBool)) Source #
pkeysEqualUnsorted :: forall (k :: PType) (a :: PType) (b :: PType) (s :: S). (PIsData k, PIsData a, PIsData b) => Term s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool)) Source #
As pkeysEqual
, but requires only PEq
constraints for the keys, and
works for Unsorted
PMap
s. This requires a number of equality comparisons
between keys proportional to the product of the lengths of both arguments:
that is, this function is quadratic.
Modification
pupdate :: forall (k :: PType) (v :: PType) (s :: S). (PIsData k, PIsData v, POrd k) => Term s ((v :--> PMaybe v) :--> (k :--> (PMap 'Sorted k v :--> PMap 'Sorted k v))) Source #
Given an 'updater' and a key, if the key exists in the PMap
, apply the
'updater' to it, otherwise do nothing. If the 'updater' produces
PNothing
, the value is deleted; otherwise, it is modified to the result.
Performance will be equivalent to a lookup followed by an insert (or delete), as well as the cost of calling the 'updater'.
padjust :: forall (k :: PType) (v :: PType) (s :: S). (PIsData k, PEq k, PIsData v) => Term s ((v :--> v) :--> (k :--> (PMap 'Unsorted k v :--> PMap 'Unsorted k v))) Source #
If a value exists at the specified key, apply the function argument to it; otherwise, do nothing.
pmapWithKey :: forall (k :: PType) (a :: PType) (b :: PType) (keysort :: KeyGuarantees) (s :: S). (PIsData k, PIsData a, PIsData b) => Term s ((k :--> (a :--> b)) :--> (PMap keysort k a :--> PMap 'Unsorted k b)) Source #
Like regular fmap
but it provides key of each element that is being
modified.
Folds
pfoldMapWithKey :: forall (m :: PType) (k :: PType) (v :: PType) (s :: S). (PIsData k, PIsData v, forall (s' :: S). Monoid (Term s' m)) => Term s ((k :--> (v :--> m)) :--> (PMap 'Sorted k v :--> m)) Source #
Project all key-value pairs into a Monoid
, then combine. Keys and values
will be presented in key order.
pfoldlWithKey :: forall (a :: PType) (k :: PType) (v :: PType) (s :: S). (PIsData k, PIsData v) => Term s ((a :--> (k :--> (v :--> a))) :--> (a :--> (PMap 'Sorted k v :--> a))) Source #
Left-associative fold of a PMap
with keys. Keys and values will be
presented in key order.
Conversion
pkeys :: forall (ell :: PType -> PType) (k :: PType) (v :: PType) (keys :: KeyGuarantees) (s :: S). (PListLike ell, PElemConstraint ell (PAsData k)) => Term s (PMap keys k v :--> ell (PAsData k)) Source #
Get a list-like structure full of the keys of the argument PMap
. If the
PMap
is Sorted
, the keys will maintain that order, and will be unique;
otherwise, the order is unspecified, and duplicates may exist.
Note
You will need to specify what manner of list-like structure you want; we have
arranged the type signature to make specifying this easy with
TypeApplications
.
Key-value pair manipulation
pkvPairKey :: forall (k :: PType) (v :: PType) (s :: S). PIsData k => Term s (PBuiltinPair (PAsData k) (PAsData v) :--> k) Source #
Get the key of a key-value pair.
pkvPairValue :: forall (k :: PType) (v :: PType) (s :: S). PIsData v => Term s (PBuiltinPair (PAsData k) (PAsData v) :--> v) Source #
Get the value of a key-value pair.
pkvPairLt :: forall (k :: PType) (v :: PType) (s :: S). (PIsData k, PPartialOrd k) => Term s (PBuiltinPair (PAsData k) (PAsData v) :--> (PBuiltinPair (PAsData k) (PAsData v) :--> PBool)) Source #
Compare two key-value pairs by their keys. Gives PTrue
if the key of the
first argument pair is less than the key of the second argument pair.