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

Data.Vector.Fixed.Internal.Arity

Description

Type class for working with N-ary functions

Synopsis

• data Z
• data S n
• type N1 = S Z
• type N2 = S N1
• type N3 = S N2
• type N4 = S N3
• type N5 = S N4
• type N6 = S N5
• type family Fn n a b
• newtype Fun n a b = Fun (Fn n a b)
• class Arity n where
• accum :: (forall k. t (S k) -> a -> t k) -> (t Z -> b) -> t n -> Fn n a b
• accumM :: Monad m => (forall k. t (S k) -> a -> m (t k)) -> (t Z -> m b) -> m (t n) -> Fn n a (m b)
• apply :: (forall k. t (S k) -> (a, t k)) -> t n -> Fn n a b -> b
• applyM :: Monad m => (forall k. t (S k) -> m (a, t k)) -> t n -> Fn n a (m b) -> m b
• arity :: n -> Int

Type-level naturals

data Z Source

Type level zero

Instances

 Arity Z

data S n Source

Successor of n

Instances

 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 (Fn n a b)

Instances

 Arity n => Functor (Fun n a)

class Arity n whereSource

Type class for handling n-ary functions.

Methods

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.

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

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

Apply all parameters to the function.

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