fixed-vector-0.4.3.0: Generic vectors with statically known size.

Safe HaskellSafe-Inferred

Data.Vector.Fixed.Internal.Arity

Contents

Description

Type class for working with N-ary functions

Synopsis

Type-level naturals

data Z Source

Type level zero

Instances

data S n Source

Successor of n

Instances

Typeable1 S 
Arity n => Arity (S n) 

Synonyms for small numerals

type N1 = S ZSource

type N2 = S N1Source

type N3 = S N2Source

type N4 = S N3Source

type N5 = S N4Source

type N6 = S N5Source

N-ary functions

type family Fn n a b Source

Type family for n-ary functions.

newtype Fun n a b Source

Newtype wrapper which is used to make Fn injective.

Constructors

Fun 

Fields

unFun :: Fn n a b
 

Instances

Arity n => Functor (Fun n a) 

class Arity n whereSource

Type class for handling n-ary functions.

Methods

accumSource

Arguments

:: (forall k. t (S k) -> a -> t k)

Fold function

-> (t Z -> b)

Extract result of fold

-> t n

Initial value

-> Fn n a b

Reduction function

Left fold over n elements exposed as n-ary function.

accumMSource

Arguments

:: Monad m 
=> (forall k. t (S k) -> a -> m (t k))

Fold function

-> (t Z -> m b)

Extract result of fold

-> m (t n)

Initial value

-> Fn n a (m b)

Reduction function

Monadic left fold.

applyFunSource

Arguments

:: (forall k. t (S k) -> (a, t k))

Get value to apply to function

-> t n

Initial value

-> Fn n a b

N-ary function

-> (b, t Z) 

Apply all parameters to the function.

applyFunMSource

Arguments

:: Monad m 
=> (forall k. t (S k) -> m (a, t k))

Get value to apply to function

-> t n

Initial value

-> Fn n a (m b)

N-ary function

-> m (b, t Z) 

Monadic apply

arity :: n -> IntSource

Arity of function.

Instances

Arity Z 
Arity n => Arity (S n) 

applySource

Arguments

:: Arity n 
=> (forall k. t (S k) -> (a, t k))

Get value to apply to function

-> t n

Initial value

-> Fn n a b

N-ary function

-> b 

Apply all parameters to the function.

applyMSource

Arguments

:: (Arity n, Monad m) 
=> (forall k. t (S k) -> m (a, t k))

Get value to apply to function

-> t n

Initial value

-> Fn n a (m b)

N-ary function

-> m b 

Apply all parameters to the function.