ntype-0.1.0.0: N-ary sum/product types

Safe HaskellSafe
LanguageHaskell2010

NType

Contents

Synopsis

General definitions

type family AllConstrained c ts :: Constraint where ... Source #

Equations

AllConstrained c '[] = () 
AllConstrained c (t ': ts) = (c t, AllConstrained c ts) 

type family IdentityElement (tensor :: Type -> Type -> Type) Source #

Instances
type IdentityElement Either Source # 
Instance details

Defined in NType

type IdentityElement (,) Source # 
Instance details

Defined in NType

class MonoidOf tensor m where Source #

Minimal complete definition

mu, eta

Methods

mu :: tensor m m -> m Source #

eta :: IdentityElement tensor -> m Source #

Instances
MonoidOf Either m Source # 
Instance details

Defined in NType

Methods

mu :: Either m m -> m Source #

eta :: IdentityElement Either -> m Source #

Monoid m => MonoidOf (,) m Source # 
Instance details

Defined in NType

Methods

mu :: (m, m) -> m Source #

eta :: IdentityElement (,) -> m Source #

data N :: (Type -> Type -> Type) -> (k -> Type) -> [k] -> Type where Source #

Constructors

Base :: !(IdentityElement tensor) -> N tensor f '[] 
Step :: !(tensor (f x) (N tensor f xs)) -> N tensor f (x ': xs) 
Instances
Eq (tensor (f x) (N tensor f xs)) => Eq (N tensor f (x ': xs)) Source # 
Instance details

Defined in NType

Methods

(==) :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> Bool #

(/=) :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> Bool #

Eq (IdentityElement tensor) => Eq (N tensor f ([] :: [k])) Source # 
Instance details

Defined in NType

Methods

(==) :: N tensor f [] -> N tensor f [] -> Bool #

(/=) :: N tensor f [] -> N tensor f [] -> Bool #

Ord (tensor (f x) (N tensor f xs)) => Ord (N tensor f (x ': xs)) Source # 
Instance details

Defined in NType

Methods

compare :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> Ordering #

(<) :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> Bool #

(<=) :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> Bool #

(>) :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> Bool #

(>=) :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> Bool #

max :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> N tensor f (x ': xs) #

min :: N tensor f (x ': xs) -> N tensor f (x ': xs) -> N tensor f (x ': xs) #

Ord (IdentityElement tensor) => Ord (N tensor f ([] :: [k])) Source # 
Instance details

Defined in NType

Methods

compare :: N tensor f [] -> N tensor f [] -> Ordering #

(<) :: N tensor f [] -> N tensor f [] -> Bool #

(<=) :: N tensor f [] -> N tensor f [] -> Bool #

(>) :: N tensor f [] -> N tensor f [] -> Bool #

(>=) :: N tensor f [] -> N tensor f [] -> Bool #

max :: N tensor f [] -> N tensor f [] -> N tensor f [] #

min :: N tensor f [] -> N tensor f [] -> N tensor f [] #

Show (tensor (f x) (N tensor f xs)) => Show (N tensor f (x ': xs)) Source # 
Instance details

Defined in NType

Methods

showsPrec :: Int -> N tensor f (x ': xs) -> ShowS #

show :: N tensor f (x ': xs) -> String #

showList :: [N tensor f (x ': xs)] -> ShowS #

Show (IdentityElement tensor) => Show (N tensor f ([] :: [k])) Source # 
Instance details

Defined in NType

Methods

showsPrec :: Int -> N tensor f [] -> ShowS #

show :: N tensor f [] -> String #

showList :: [N tensor f []] -> ShowS #

nmap :: forall f g tensor. Bifunctor tensor => (forall x. f x -> g x) -> forall xs. N tensor f xs -> N tensor g xs Source #

nmapConstrained :: forall c f g tensor. Bifunctor tensor => (forall x. c x => f x -> g x) -> forall xs. AllConstrained c xs => N tensor f xs -> N tensor g xs Source #

nfold :: forall f r tensor. (Bifunctor tensor, MonoidOf tensor r) => (forall x. f x -> r) -> forall xs. N tensor f xs -> r Source #

nfoldConstrained :: forall c f r tensor. (Bifunctor tensor, MonoidOf tensor r) => (forall x. c x => f x -> r) -> forall xs. AllConstrained c xs => N tensor f xs -> r Source #

Product types

type Rec = N (,) Source #

rmap :: forall f g. (forall x. f x -> g x) -> forall xs. Rec f xs -> Rec g xs Source #

rmapConstrained :: forall c f g. (forall x. c x => f x -> g x) -> forall xs. AllConstrained c xs => Rec f xs -> Rec g xs Source #

rfold :: forall f r. Monoid r => (forall x. f x -> r) -> forall xs. Rec f xs -> r Source #

rfoldConstrained :: forall c f r. Monoid r => (forall x. c x => f x -> r) -> forall xs. AllConstrained c xs => Rec f xs -> r Source #

rget :: forall f xs a. Elem xs a => Rec f xs -> f a Source #

class KnownSpine xs where Source #

Minimal complete definition

knownSpine

Methods

knownSpine :: Spine xs Source #

Instances
KnownSpine ([] :: [k]) Source # 
Instance details

Defined in NType

Methods

knownSpine :: Spine [] Source #

KnownSpine xs => KnownSpine (x ': xs :: [k]) Source # 
Instance details

Defined in NType

Methods

knownSpine :: Spine (x ': xs) Source #

Sum types

umap :: forall f g. (forall x. f x -> g x) -> forall xs. Union f xs -> Union g xs Source #

umapConstrained :: forall c f g. (forall x. c x => f x -> g x) -> forall xs. AllConstrained c xs => Union f xs -> Union g xs Source #

ufold :: forall f r. (forall x. f x -> r) -> forall xs. Union f xs -> r Source #

ufoldConstrained :: forall c f r. (forall x. c x => f x -> r) -> forall xs. AllConstrained c xs => Union f xs -> r Source #

umatch :: forall f xs a. Elem xs a => Union f xs -> Maybe (f a) Source #

ulift :: forall f xs a. Elem xs a => f a -> Union f xs Source #

type ElemEv a = Union ((:~:) a) Source #

class Elem' (Index x xs) x xs => Elem xs x Source #

Instances
Elem' (Index x xs) x xs => Elem (xs :: [k]) (x :: k) Source # 
Instance details

Defined in NType

elemEv :: forall xs a. Elem xs a => ElemEv a xs Source #