HCont : Type -> Type -> Type A heterogeneous container indexed over a container type `l`
holding values of type `k`.
Totality: total
Visibility: public exportinterface HPure : (k : Type) -> (l : Type) -> HCont k l -> Type This interface allows a heterogenous product to be filled
with values, given a function which produce values of
every possible type required.
@ k kind of Types in a heterogeneous container's type level code
@ l kind of container used to describe a heterogeneous containr's type
level code
@ p the heterogeneous sum or product
Parameters: k, l, p
Methods:
hpure : f a -> p f ks Creates a heterogeneous product by using the given functio
to produce values.
```idris example
Person : (f : Type -> Type) -> Type
Person f = NP f [String,Int]
emptyPerson : Person Maybe
emptyPerson = hpure Nothing
```
Implementations:
HPure k (List k) (NP_ k) HPure k (List (List k)) (POP_ k)
hpure : HPure k l p => f a -> p f ks Creates a heterogeneous product by using the given functio
to produce values.
```idris example
Person : (f : Type -> Type) -> Type
Person f = NP f [String,Int]
emptyPerson : Person Maybe
emptyPerson = hpure Nothing
```
Totality: total
Visibility: public exporthempty : Alternative f => HPure Type l p => p f ks Alias for `hpure empty`.
```idris example
Person : (f : Type -> Type) -> Type
Person f = NP f [String,Int]
emptyPerson : Person Maybe
emptyPerson = empty
```
Totality: total
Visibility: public exporthconst : HPure k l p => a -> p (K a) ks Fills a heterogeneous structure with a constant value
in the (K a) functor.
```idris example
Person : (f : Type -> Type) -> Type
Person f = NP f [String,Int]
fooPerson : Person (K String)
fooPerson = hconst "foo"
```
Totality: total
Visibility: public exportinterface HFunctor : (k : Type) -> (l : Type) -> HCont k l -> Type A higher kinded functor allowing us to change the
wrapper type or context of an n-ary sum or product.
@ k kind of Types in a heterogeneous container's type level code
@ l kind of container used to describe a heterogeneous containr's type
level code
@ p the actual heterogeneous container
Parameters: k, l, p
Methods:
hmap : (f a -> g a) -> p f ks -> p g ks Maps the given function over all values in a
heterogeneous container, thus changing the context
of all of its values.
@ fun maps values in a heterogeneous container to a new context
@ p the heterogeneous container, over which `fun` is mapped.
```idris example
Person : (f : Type -> Type) -> Type
Person f = NP f [String,Int]
toPersonMaybe : Person I -> Person Maybe
toPersonMaybe = hmap Just
```
Implementations:
HFunctor k (List k) (NS_ k) HFunctor k (List k) (NP_ k) HFunctor k (List (List k)) (POP_ k) HFunctor k (List (List k)) (SOP_ k)
hmap : HFunctor k l p => (f a -> g a) -> p f ks -> p g ks Maps the given function over all values in a
heterogeneous container, thus changing the context
of all of its values.
@ fun maps values in a heterogeneous container to a new context
@ p the heterogeneous container, over which `fun` is mapped.
```idris example
Person : (f : Type -> Type) -> Type
Person f = NP f [String,Int]
toPersonMaybe : Person I -> Person Maybe
toPersonMaybe = hmap Just
```
Totality: total
Visibility: public exporthliftA : HFunctor k l p => (f a -> g a) -> p f ks -> p g ks Alias for `hmap`
Totality: total
Visibility: public exporthcpure : HFunctor k l p => (0 c : (k -> Type)) -> p c ks => (c a => f a) -> p f ks Like `hpure` but using a constrained function for
generating values. Since Idris is able to provide
the required constraints
already wrapped in a container of the correct
shape, this is actually a derivative of `HFunctor` and not
`HPure`. This has interesting consequences for sum
types, for which this function is available as well.
Since Idris has to choose a value of the sum
itself, it will use the first possibility it
can fill with the requested constraints.
In the first example below, Idris generates the value
`MkSOP (Z ["","",[]])`. However, if the first choice does
not have a Monoid instance, Idris faithfully chooses the
next working possibility. In the second example,
the result is `MkSOP (S (Z [[],[]]))`:
```idris example
neutralFoo : SOP I [[String,String,List Int],[Int]]
neutralFoo = hcpure Monoid neutral
neutralBar : SOP I [[String,Int,List Int],[List String, List Int]]
neutralBar = hcpure Monoid neutral
```
@ c erased function argument to specify the constraint
to use
@ fun generates values depending on the availability of
a constraint
Totality: total
Visibility: public exportinterface HAp : (k : Type) -> (l : Type) -> ((k -> Type) -> l -> Type) -> ((k -> Type) -> l -> Type) -> Type Like `Applicative`, this interface allows to
map arbitrary n-ary Rank-2 functions over
heterogeneous data structures of the same shape.
However, in order to support products as well as sum types
all arguments except the last one have to be products
indexed over the same container as the last argument.
@ k kind of Types in a heterogeneous container's type level code
@ l kind of container used to describe a heterogeneous containr's type
level code
@ q heterogeneous product related to `p`. For product types,
this is the same as `p`, for sum types it is the corresponding
product type.
@ p the actual heterogeneous container (sum or product)
Parameters: k, l, q, p
Constraints: HFunctor k l q, HFunctor k l p
Methods:
hap : q (\a => f a -> g a) ks -> p f ks -> p g ks Higher kinded equivalent to `(<*>)`.
Applies wrapped functions in the product
container to the corresponding values in the
second container.
@ q product holding unary Rank-2 functions.
@ p sum or product to whose values the functions in `q` should
be applied
```idris example
hapTest : SOP Maybe [[String,Int]] -> SOP I [[String,Int]]
hapTest = hap (MkPOP $ [[fromMaybe "foo", const 12]])
```
Implementations:
HAp k (List k) (NP_ k) (NS_ k) HAp k (List k) (NP_ k) (NP_ k) HAp k (List (List k)) (POP_ k) (POP_ k) HAp k (List (List k)) (POP_ k) (SOP_ k)
hap : HAp k l q p => q (\a => f a -> g a) ks -> p f ks -> p g ks Higher kinded equivalent to `(<*>)`.
Applies wrapped functions in the product
container to the corresponding values in the
second container.
@ q product holding unary Rank-2 functions.
@ p sum or product to whose values the functions in `q` should
be applied
```idris example
hapTest : SOP Maybe [[String,Int]] -> SOP I [[String,Int]]
hapTest = hap (MkPOP $ [[fromMaybe "foo", const 12]])
```
Totality: total
Visibility: public exporthliftA2 : HAp k l q p => (f a -> g a -> h a) -> q f ks -> p g ks -> p h ks Higher kinded version of `liftA2`.
This is a generalization of `hliftA` to binary
functions.
Totality: total
Visibility: public exporthliftA3 : HAp k l q q => HAp k l q p => (f a -> g a -> h a -> i a) -> q f ks -> q g ks -> p h ks -> p i ks Higher kinded version of `liftA3`.
This is a generalization of `hliftA` to ternary
functions.
Totality: total
Visibility: public exporthliftA4 : HAp k l q q => HAp k l q p => (f a -> g a -> h a -> i a -> j a) -> q f ks -> q g ks -> q h ks -> p i ks -> p j ks Higher kinded version of `liftA4`.
This is a generalization of `hliftA` to quartenary
functions.
Totality: total
Visibility: public exporthcmap : HAp k l q p => (0 c : (k -> Type)) -> q c ks => (c a => f a -> g a) -> p f ks -> p g ks Like `hmap` but uses a constrained function.
@ c constraint used to convert values
@ fun constrained function for converting values to
a new context
```idris example
showValues : NP I [String,Int] -> NP (K String) [String,Int]
showValues = hcmap Show show
```
Totality: total
Visibility: public exporthcliftA : HAp k l q p => (0 c : (k -> Type)) -> q c ks -> (c a => f a -> g a) -> p f ks -> p g ks Alias for `hcmap`
Totality: total
Visibility: public exporthcliftA2 : HAp k l q q => HAp k l q p => (0 c : (k -> Type)) -> q c ks => (c a => f a -> g a -> h a) -> q f ks -> p g ks -> p h ks Like `hliftA2` but with a constrained function.
Totality: total
Visibility: public exporthcliftA3 : HAp k l q q => HAp k l q p => (c : (k -> Type)) -> q c ks => (c a => f a -> g a -> h a -> i a) -> q f ks -> q g ks -> p h ks -> p i ks Like `hliftA3` but with a constrained function.
Totality: total
Visibility: public exportinterface HFold : (k : Type) -> (l : Type) -> HCont k l -> Type- Parameters: k, l, p
Methods:
hfoldl : (acc -> el -> acc) -> acc -> p (K el) ks -> acc Strict fold over a heterogeneous sum or product
parameterized by the constant functor (and thus being actually
a homogeneous sum or product).
hfoldr : (el -> Lazy acc -> acc) -> Lazy acc -> p (K el) ks -> acc Lazy fold over a heterogeneous sum or product
parameterized by the constant functor (and thus being actually
a homogeneous sum or product).
Implementations:
HFold k (List k) (NS_ k) HFold k (List k) (NP_ k) HFold k (List (List k)) (POP_ k) HFold k (List (List k)) (SOP_ k)
hfoldl : HFold k l p => (acc -> el -> acc) -> acc -> p (K el) ks -> acc Strict fold over a heterogeneous sum or product
parameterized by the constant functor (and thus being actually
a homogeneous sum or product).
Totality: total
Visibility: public exporthfoldr : HFold k l p => (el -> Lazy acc -> acc) -> Lazy acc -> p (K el) ks -> acc Lazy fold over a heterogeneous sum or product
parameterized by the constant functor (and thus being actually
a homogeneous sum or product).
Totality: total
Visibility: public exporthsize : (HFunctor k l p, HFold k l p) => p f ks -> Nat Calculates the size of a heterogeneous container
Totality: total
Visibility: public exporthconcat : (Monoid m, HFold k l p) => p (K m) ks -> m Alias for `hfoldl (<+>) neutral`.
Totality: total
Visibility: public exporthconcatMap : Monoid m => HFunctor k l p => HFold k l p => (f a -> m) -> p f ks -> m Alias for `hconcat . hmap fun`
Totality: total
Visibility: public exporthcconcatMap : Monoid m => HAp k l q p => HFold k l p => (0 c : (k -> Type)) -> q c ks => (c a => f a -> m) -> p f ks -> m Alias for `hconcat . hcmap c fun`
Totality: total
Visibility: public exporthsequence_ : (Applicative g, HFold k l p) => p (K (g ())) ks -> g () Generalization of `sequence_` to heterogeneous containers.
Alias for `hfoldl (*>) (pure ())`.
Totality: total
Visibility: public exporthtraverse_ : Applicative g => HFunctor k l p => HFold k l p => (f a -> g ()) -> p f ks -> g () Generalization of `traverse_` to heterogeneous containers.
Alias for `hsequence_ . hmap fun`.
Totality: total
Visibility: public exporthfor_ : (Applicative g, (HFold k l p, HFunctor k l p)) => p f ks -> (f a -> g ()) -> g () Generalization of `for_` to heterogeneous containers.
Totality: total
Visibility: public exporthand : HFold k l p => p (K Bool) ks -> Bool Generalization of `and` to heterogeneous containers.
Totality: total
Visibility: public exporthtoList : (HFunctor k l p, HFold k l p) => p (K a) ks -> List a Generalization of `toList` to heterogeneous containers.
Totality: total
Visibility: exporthor : HFold k l p => p (K Bool) ks -> Bool Generalization of `or` to heterogeneous containers.
Totality: total
Visibility: exporthall : HFunctor k l p => HFold k l p => (f a -> Bool) -> p f ks -> Bool Generalization of `all` to heterogeneous containers.
Totality: total
Visibility: exporthany : HFunctor k l p => HFold k l p => (f a -> Bool) -> p f ks -> Bool Generalization of `any` to heterogeneous containers.
Totality: total
Visibility: exporthchoice : HFold k l p => Alternative f => p (K (f a)) ks -> f a Generalization of `choice` to heterogeneous containers.
Totality: total
Visibility: exportinterface HSequence : (k : Type) -> (l : Type) -> HCont k l -> Type Sequencing of applicative effects over a heterogeneous
container.
Parameters: k, l, p
Methods:
hsequence : Applicative g => p (\a => g (f a)) ks -> g (p f ks) Given a heterogeneous containers holding values
wrapped in effect `g`, sequences applications of
`g` to the outside of the heterogeneous container.
```idris example
seqMaybe : NP Maybe [Int,String] -> Maybe (NP I [Int,String])
seqMaybe = hsequence
```
Implementations:
HSequence k (List k) (NS_ k) HSequence k (List k) (NP_ k) HSequence k (List (List k)) (POP_ k) HSequence k (List (List k)) (SOP_ k)
hsequence : HSequence k l p => Applicative g => p (\a => g (f a)) ks -> g (p f ks) Given a heterogeneous containers holding values
wrapped in effect `g`, sequences applications of
`g` to the outside of the heterogeneous container.
```idris example
seqMaybe : NP Maybe [Int,String] -> Maybe (NP I [Int,String])
seqMaybe = hsequence
```
Totality: total
Visibility: public exporthtraverse : Applicative g => HFunctor k l p => HSequence k l p => (f a -> g (f' a)) -> p f ks -> g (p f' ks) Traverses a heterogeneous container by applying effectful
function `fun`.
```idris example
htraverseEx : NP (Either String) [Int,String] -> Maybe (NP I [Int,String])
htraverseEx = htraverse (either (const Nothing) Just)
```
Totality: total
Visibility: exporthfor : Applicative g => HFunctor k l p => HSequence k l p => p f ks -> (f a -> g (f' a)) -> g (p f' ks) Flipped version of `htraverse`.
Totality: total
Visibility: exporthctraverse : Applicative g => HAp k l q p => HSequence k l p => (0 c : (k -> Type)) -> q c ks => (c a => f a -> g (f' a)) -> p f ks -> g (p f' ks) Constrained version of `htraverse`.
```idris example
interface Read a where
read : String -> Maybe a
hctraverseEx : NP Read [Int,String] =>
NP (K String) [Int,String] -> Maybe (NP I [Int,String])
hctraverseEx = hctraverse Read read
```
Totality: total
Visibility: exporthcfor : Applicative g => HAp k l q p => HSequence k l p => (0 c : (k -> Type)) -> q c ks => p f ks -> (c a => f a -> g (f' a)) -> g (p f' ks) Flipped version of `hctraverse`.
Totality: total
Visibility: exportinterface HCollapse : (k : Type) -> (l : Type) -> HCont k l -> (Type -> Type) -> Type Collapsing a heterogeneous container to a homogeneous one
of the same shape.
Parameters: k, l, p, collapseTo
Methods:
hcollapse : p (K a) ks -> collapseTo a A heterogeneous container over constant functor `K a` is
actually a homogeneous one holding only values of type `a`.
This function extracts the wrapped values into a homogeneous
one of the same size and shape.
Implementations:
HCollapse k (List k) (NS_ k) I HCollapse k (List k) (NP_ k) List HCollapse k (List (List k)) (POP_ k) (List . List) HCollapse k (List (List k)) (SOP_ k) List
hcollapse : HCollapse k l p collapseTo => p (K a) ks -> collapseTo a A heterogeneous container over constant functor `K a` is
actually a homogeneous one holding only values of type `a`.
This function extracts the wrapped values into a homogeneous
one of the same size and shape.
Totality: total
Visibility: public export