yoko-2.0: Generic Programming with Disbanded Data Types

Portabilitysee LANGUAGE pragmas (... GHC)
Stabilityexperimental
Maintainernicolas.frisby@gmail.com
Safe HaskellNone

Data.Yoko.TypeBasics

Contents

Description

Some type-level programming basics.

Synopsis

Documentation

data Proxy a Source

A polykinded proxy.

Constructors

Proxy 

type Equal a b = IsEQ (SpineCompare a b)Source

Convenient synonym. type Equal a b = IsEQ (SpineCompare a b)

derive_data :: Name -> Q [Dec]Source

Template Haskell derivation for the type-spine and type-cereal packages' Spine and Serialize type families, which support generic instances of Compare.

data Nat Source

Constructors

Z 
S Nat 

data SingNat whereSource

Constructors

SZ :: SingNat Z 
SN :: SingNat n -> SingNat (S n) 

type Length list = Length' Z listSource

type family Length' acc list :: NatSource

type family Append x y :: [k]Source

type family App fn t :: *Source

newtype Constant a t Source

Constructors

Constant a 

data Vec whereSource

Constructors

VNil :: Vec `[]` f 
VCons :: App f t -> Vec ts f -> Vec (t : ts) f 

Instances

(Eq (App k f t), Eq (Vec k ts f)) => Eq (Vec k (: k t ts) f) 
Eq (Vec k ([] k) f) 
(Ord (App k f t), Ord (Vec k ts f)) => Ord (Vec k (: k t ts) f) 
Ord (Vec k ([] k) f) 
(Monoid (App k f t), Monoid (Vec k ts f)) => Monoid (Vec k (: k t ts) f) 
Monoid (Vec k ([] k) f) 

vCarrying :: Proxy f -> Vec ts f -> Vec ts fSource

class VFunctor c ts whereSource

Methods

vMap :: Proxy c -> (forall t. c t => Proxy t -> App f t -> App g t) -> Vec ts f -> Vec ts gSource

Instances

VFunctor k c ([] k) 
(c t, VFunctor k c ts) => VFunctor k c (: k t ts) 

class TrivCon a Source

Instances

TrivCon k a 

class VInitialize c ts whereSource

Methods

vInitialize :: Proxy c -> Proxy f -> (forall t. c t => Proxy t -> App f t) -> Vec ts fSource

cvInitialize :: Proxy c -> (forall t. c t => Proxy t -> a) -> CVec ts aSource

Instances

VInitialize k c ([] k) 
(c t, VInitialize k c ts) => VInitialize k c (: k t ts) 

newtype CVec ts a Source

Constructors

CVec 

Fields

unCVec :: Vec ts (Constant a)
 

Instances

Functor (CVec k ts) 
Foldable (CVec k ts) 
Traversable (CVec k ts) 
Eq (Vec k ts (Constant k a)) => Eq (CVec k ts a) 
Ord (Vec k ts (Constant k a)) => Ord (CVec k ts a) 
Monoid (Vec k ts (Constant k a)) => Monoid (CVec k ts a) 

cvec2list :: CVec ts a -> [a]Source

class VRepeat ts whereSource

Methods

cvRepeat :: a -> CVec ts aSource

Instances

VRepeat k ([] k) 
VRepeat k ts => VRepeat k (: k t ts) 

data Diag_ f g t Source

Constructors

Diag_ 

class VZip ts whereSource

Methods

vZip :: Vec ts f -> Vec ts g -> Vec ts (Diag_ f g)Source

Instances

VZip k ([] k) 
VZip k ts => VZip k (: k t ts) 

cvZipWith :: forall a b c ts. (a -> b -> c) -> CVec ts a -> CVec ts b -> CVec ts cSource

data Idx whereSource

Constructors

ZIdx :: Idx (t : ts) 
SIdx :: Idx ts -> Idx (t : ts) 

Instances

Eq (Idx k ts) 
Ord (Idx k ts) 
Show (Idx k ts) 

class IndexInto n ts whereSource

Methods

indexInto :: Proxy n -> Proxy ts -> Idx tsSource

Instances

IndexInto k Z (: k t ts) 
IndexInto k n ts => IndexInto k (S n) (: k t ts) 

cvAt :: forall ts a. CVec ts a -> Idx ts -> aSource

cvUpd :: forall ts a. CVec ts a -> Idx ts -> (a -> a) -> CVec ts aSource

class VEnum ts whereSource

Methods

cvEnum :: CVec ts (Idx ts)Source

Instances

VEnum k ([] k) 
VEnum k ts => VEnum k (: k t ts) 

cvAddIndexes :: VEnum ts => CVec ts a -> CVec ts (Idx ts, a)Source

Re-exports

Type-level Maybe

type family IsJust x :: BoolSource

Returns a type-level boolean from type-booleans.

type family MaybePlus1 x y :: Maybe kSource

Type-level mplus for Maybe.

type family MaybeMap f x :: Maybe lSource

Type-level fmap for Maybe.

type family If c a b :: kSource

encode :: Serialize a => a -> Type

Encode uses the cereal package serializer to encode the value and then uses type-digits to reflect it as a type-level numeral.

type SpineCompare l r = Compare * (Spine k l) (Spine k1 r)