Idris2Doc : Data.SOP.NP

Data.SOP.NP

(source)

Definitions

dataNP_ : (k : Type) -> (k->Type) ->Listk->Type
  An n-ary product.

The product is parameterized by a type constructor f and indexed by a
type-level list ks. The length of the list determines the number of
elements in the product, and if the i-th element of the list is of type k,
then the i-th element of the product is of type f k.

Two common instantiations of f are the identity functor I and the constant
functor K. For I, the product becomes a heterogeneous list, where the
type-level list describes the types of its components. For K a, the product
becomes a homogeneous list, where the contents of the type-level list are
ignored, but its length still specifies the number of elements.

In the context of the SOP approach to generic programming, an n-ary product
describes the structure of the arguments of a single data constructor.

Note: `NP_` takes an additional type parameter `k` to simulate
Haskell's kind polymorphism. In theory, this could be left
as an implicit argument. However, type-inference when calling
interface functions like `hpure` was rather poor with `k`
being implicit.

We therefore made `k` explicit and added a type alias `NP`
to be used in those occasions when `k` can be inferred.

Examples:

```idris example
ex1 : NP I [Char,Bool]
ex1 = ['c',False]

ex2 : NP (K String) [Char,Bool,Int]
ex2 = ["Hello","World","!"]

ex3 : NP Maybe [Char,Bool,Int]
ex3 = [Just 'x', Nothing, Just 1]
```

Totality: total
Visibility: public export
Constructors:
Nil : NP_kf []
(::) : ft->NP_kfks->NP_kf (t::ks)

Hints:
NP (DecEq.f) ks=>DecEq (NP_kfks)
NP (Eq.f) ks=>Eq (NP_kfks)
HApk (Listk) (NP_k) (NS_k)
HApk (Listk) (NP_k) (NP_k)
HCollapsek (Listk) (NP_k) List
HFoldk (Listk) (NP_k)
HFunctork (Listk) (NP_k)
HPurek (Listk) (NP_k)
HSequencek (Listk) (NP_k)
NP (Monoid.f) ks=>Monoid (NP_kfks)
POP_k (c.f) kss-> (NP_k (c.f) ks=>c (NP_kfks)) =>NP_ (Listk) (c.NP_kf) kss
NP (Ord.f) ks=>Ord (NP_kfks)
NP (Semigroup.f) ks=>Semigroup (NP_kfks)
NP (Show.f) ks=>Show (NP_kfks)
NP : (k->Type) ->Listk->Type
  Type alias for `NP_` with type parameter `k` being
implicit. This reflects the kind-polymorphic data type
in Haskell.

Totality: total
Visibility: public export
toI : NP_kfks->NPI (mapfks)
  Changes an n-ary product to the identity context `I`
by adjusting the types of stored values accordingly.

Totality: total
Visibility: public export
mapNP : (fa->ga) ->NPfks->NPgks
  Specialiced version of `hmap`

Totality: total
Visibility: public export
pureNP : fa->NPfks
  Specialization of `hpure`.

Totality: total
Visibility: public export
hapNP : NP (\a=>fa->ga) ks->NPfks->NPgks
  Specialization of `hap`.

Totality: total
Visibility: public export
foldlNP : (acc->el->acc) ->acc->NP (Kel) ks->acc
  Specialization of `hfoldl`

Totality: total
Visibility: public export
foldrNP : (el-> Lazy acc->acc) -> Lazy acc->NP (Kel) ks->acc
  Specialization of `hfoldr`

Totality: total
Visibility: public export
sequenceNP : Applicativeg=>NP (\a=>g (fa)) ks->g (NPfks)
  Specialization of `hsequence`

Totality: total
Visibility: public export
collapseNP : NP (Ka) ks->Lista
  Specialization of `hcollapse`

Totality: total
Visibility: public export
hd : NPf (k::ks) ->fk
  Returns the head of a non-empty n-ary product

Totality: total
Visibility: public export
tl : NPf (k::ks) ->NPfks
  Returns the tail of a non-empty n-ary product

Totality: total
Visibility: public export
fromListNP : NPfks->Lista->Maybe (NP (Ka) ks)
  Tries to creates a homogeneous n-ary product of the given
shape from a list of values.

Totality: total
Visibility: public export
fromList : Lista->Maybe (NP (Ka) ks)
  Like `fromListNP` but takes the shape from the implicit
list of types.

Totality: total
Visibility: public export
unfoldNP : NPfks-> (s-> (s, a)) ->s->NP (Ka) ks
  Creates a homogeneous n-ary product of the given
shape by repeatedly applying a function to a seed value.

Totality: total
Visibility: public export
unfold : (s-> (s, a)) ->s->NP (Ka) ks
  Like `unfoldNP` but takes the shape from the implicit
list of types.

Totality: total
Visibility: public export
iterateNP : NPfks-> (a->a) ->a->NP (Ka) ks
  Creates a homogeneous n-ary product of the given
shape using an initial value and a function for
generating the next value.

Totality: total
Visibility: public export
iterate : (a->a) ->a->NP (Ka) ks
  Like `iterate` but takes the shape from the implicit
list of types.

Totality: total
Visibility: public export
0Projection : (k->Type) ->Listk->k->Type
  A projection of an n-ary product p extracts the
value of p at a certain position.

Totality: total
Visibility: public export
projections : NP (Projectionfks) ks
  The set of projections of an n-ary product `NP f ks` can
itself be wrapped in an n-ary product of the same shape.

Totality: total
Visibility: public export
get : (0t : k) ->Elemtks=>NP_kfks->ft
  Access the first element of the given type in
an n-ary product

Totality: total
Visibility: public export
modify : (ft->ft') ->UpdateOncett'ksks'=>NP_kfks->NP_kfks'
  Modify a single element of the given type
in an n-ary product, thereby possibly changing the
types of stored values.

Totality: total
Visibility: public export
modifyF : Functorg=> (ft->g (ft')) ->UpdateOncett'ksks'=>NP_kfks->g (NP_kfks')
  Modify a single element of the given type
in an n-ary product by applying an effectful
function.

This is the effectful version of `modify`.

Totality: total
Visibility: public export
modifyMany : (ft->ft') ->UpdateManytt'ksks'=>NP_kfks->NP_kfks'
  Modify several elements of the given type
in an n-ary product, thereby possibly changing the
types of stored values.

Totality: total
Visibility: public export
modifyManyF : Applicativeg=> (ft->g (ft')) ->UpdateManytt'ksks'=>NP_kfks->g (NP_kfks')
  Modify several elements of the given type
in an n-ary product by applying an effectful function.

This is the effectful version of `modifyMany`.

Totality: total
Visibility: public export
setAt : (0t : k) ->ft'->UpdateOncett'ksks'=>NP_kfks->NP_kfks'
  Replaces the first element of the given type
in an n-ary product, thereby possibly changing the
types of stored values.

Totality: total
Visibility: public export
setAtMany : (0t : k) ->ft'->UpdateManytt'ksks'=>NP_kfks->NP_kfks'
  Replaces several elements of the given type
in an n-ary product, thereby possibly changing the
types of stored values.

Totality: total
Visibility: public export
setAt' : (0t : k) -> (0t' : k) ->ft'->UpdateOncett'ksks'=>NP_kfks->NP_kfks'
  Alias for `setAt` for those occasions when
Idris cannot infer the type of the new value.

Totality: total
Visibility: public export
setAtMany' : (0t : k) -> (0t' : k) ->ft'->UpdateManytt'ksks'=>NP_kfks->NP_kfks'
  Alias for `setAtMany` for those occasions when
Idris cannot infer the type of the new value.

Totality: total
Visibility: public export
narrow : NPfks->Sublistks'ks=>NPfks'
  Extracts a subset of values from an n-ary product.
The values must appear in the same order in both lists.

Totality: total
Visibility: public export
append : NPfks->NPfks'->NPf (ks++ks')
  Appends two n-ary products.

Totality: total
Visibility: public export
expand : fk->NPfks->Sublistksks'=>NPfks'
  Expands an n-ary product by filling missing
values with the given default-generating function.

Totality: total
Visibility: public export
cexpand : (0c : (k->Type)) ->NPcks'=> (ck=>fk) ->Sublistksks'=>NP_kfks->NP_kfks'
  Expands an n-ary product by filling missing
values with the given default-generating function.

This is the constrained version of `expand`.

Totality: total
Visibility: public export
ordToEqNP : NP (Ord.f) ks->NP (Eq.f) ks
  This is needed to implement `Ord` below.

Totality: total
Visibility: public export
monoidToSemigroupNP : NP (Monoid.f) ks->NP (Semigroup.f) ks
  This is needed to implement `Monoid` below.

Totality: total
Visibility: public export