Idris2Doc : Data.FVect

Data.FVect

(source)
Fin-based vects encode not just their current size but also their
largest size. See also Data.FVect.Capacity for a view that is
useful when determining if you want to add to an FVect depending
on whether or not it is full.

Reexports

importpublic Data.Fin

Definitions

dataFVect : (capacity : Nat) ->Fin (Scapacity) ->Type->Type
  A Fin-based Vect. Can be thought of as a Vect with both a length
and a maximum capacity. Operations like filtering can reduce the
length without affecting maximum capacity which provides proof
that a Vect's length has not increased over the course of a series
of operations.

Totality: total
Visibility: public export
Constructors:
Nil : FVectcapacityFZelem
(::) : elem->FVectcapacitylenelem->FVect (Scapacity) (FSlen) elem
  Cons an element to the FVect, increasing its capacity.
See (:::) for an operator that conses an element without
increasing capacity.

Hints:
Applicative (FVectcapacityl)
DecEqelem=>DecEq (FVectclelem)
Eqelem=>Eq (FVectclelem)
Foldable (FVectcl)
Functor (FVectcl)
Uninhabited (FVect0 (FSl) e)
consWeaker : elem->FVect (Sn) (weakenlen') elem->FVect (Sn) (FSlen') elem
  Cons an element without increasing the capacity of the FVect. You
must make sure the capacity and length of the FVect being consed
onto are accessible in the context where you call this.

The function signature is a bit tricky because it needs to ensure
you are going from length of type Fin n to length of type Fin n
but calling Fin's FS constructor increments n. To increment the
value stored without weakening the bounds of the Fin, we go from
(weaken (Fin (S n))) to (FS (Fin (S n))).

In other words, we go from a weaker input Fin to the succesor of a
stronger bounded Fin.

Totality: total
Visibility: public export
strengthenLT : (j : Fin (Sn)) -> {auto0_ : LT (finToNatj) n} ->Finn
Totality: total
Visibility: public export
consLT : {auto0ltPrf : LT (finToNatlen) (Sn)} ->elem->FVect (Sn) lenelem->FVect (Sn) (FS (strengthenLTlen)) elem
  Like `consWeaker`, cons an element onto an FVect without changing
its capacity.

You need only know that the existing FVect is not at capacity to
know that an element can be consed onto it without increasing the
capacity.

Totality: total
Visibility: public export
(:::) : {auto0ltPrf : LT (finToNatlen) (Sn)} ->elem->FVect (Sn) lenelem->FVect (Sn) (FS (strengthenLTlen)) elem
  Like `consWeaker`, cons an element onto an FVect without changing
its capacity.

You need only know that the existing FVect is not at capacity to
know that an element can be consed onto it without increasing the
capacity.

Totality: total
Visibility: public export
Fixity Declaration: infixr operator, level 7
empty : (capacity : Nat) ->FVectcapacityFZelem
  Create an empty FVect with the given capacity.

Totality: total
Visibility: export
replicate : (l : Fin (Scapacity)) ->elem->FVectcapacitylelem
  Create an FVect by replicating the given element enough to fill
the needed length.

Totality: total
Visibility: export
addCapacity : FVectcla->FVect (Sc) (weakenl) a
  Allow FVect to hold one more element. 
Do not change the elements currently in the FVect.

Totality: total
Visibility: public export
addCapacityN : (n : Nat) ->FVectcapacityla->FVect (capacity+n) (weakenNnl) a
  Allow FVect to hold n more elements. 
Do not change the elements currently in the FVect.

Totality: total
Visibility: public export
removeCapacity : FVect (Sn) (weakenlen') a->FVectnlen'a
  Reduce the FVect's capacity to hold elements.

Totality: total
Visibility: public export
length : FVectcapacityla->Nat
  Calculate the length of the FVect.

Totality: total
Visibility: export
fromVect : Vectla->FVectllasta
  Get the smallest FVect that can contain the given Vect.

Totality: total
Visibility: export
toVect : FVectclelem->Vect (finToNatl) elem
Totality: total
Visibility: export
tail : FVectc (FSl) elem->FVectc (weakenl) elem
  All but the first element of the FVect.
This operation does not change capacity. This means you can carry
out this operation and retain proof that the new FVect length is
less than or equal to the original FVect (although in this case
the length is exactly one less than before the call to tail).

Totality: total
Visibility: public export
dropFirst : FVect (Sc) (FSl) elem->FVectclelem
  Like tail but reduces the capacity by 1 in addition
to dropping the first element.

Totality: total
Visibility: public export
head : FVectc (FSl) elem->elem
Totality: total
Visibility: public export
last : FVectc (FSl) elem->elem
Totality: total
Visibility: public export
init : FVectc (FSl) elem->FVectc (weakenl) elem
  All but the last element of the FVect.
This operation does not change capacity. This means you can carry
out this operation and retain proof that the new FVect length is
less than or equal to the original FVect (although in this case
the length is exactly one less than before the call to tail).

Totality: total
Visibility: public export
dropLast : FVect (Sc) (FSl) elem->FVectclelem
  Like init but reduces the capacity by 1 in addition to removing
the last element.

Totality: total
Visibility: public export
fVectInjective : x::xs=y::ys-> (x=y, xs=ys)
  If two FVects are equal, their heads and tails are equal.

Totality: total
Visibility: export
addRemoveCapacityInverse : (xs : FVectclelem) ->removeCapacity (addCapacityxs) =xs
  If you add and then remove capacity, you are left with the
original capacity.
In fact, you are left with exactly the original FVect.

Totality: total
Visibility: export
lengthReifies : (v : FVectclelem) ->lengthv=finToNatl
  The calculated length of an FVect reifies the erased length of the
FVect.

Totality: total
Visibility: export
catMaybes : FVectcapacitylen (Maybeelem) -> (len' : Fin (Scapacity) **FVectcapacitylen'elem)
  Remove all Nothings from the FVect.
This operation does not change capacity. That means you can carry
out this operation and retain proof that the new FVect length is
less than or equal to that of the original FVect.

Totality: total
Visibility: export
mapMaybes : (elem->Maybeelem') ->FVectcapacitylenelem-> (len' : Fin (Scapacity) **FVectcapacitylen'elem')
  Map all elements, removing any Nothings along the way.
This operation does not change capacity. That means you can carry
out this operation and retain proof that the new FVect length is
less than or equal to that of the original FVect.

Totality: total
Visibility: export
filter : (elem->Bool) ->FVectcapacitylenelem-> (len' : Fin (Scapacity) **FVectcapacitylen'elem)
  Filter down to only elements matching the predicate.
This operation does not change capacity. That means you can carry
out this operation and retain proof that the new FVect length is
less than or equal to that of the original FVect.

Totality: total
Visibility: export