ntype-0.1.0.0: N-ary sum/product types

NType

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
 Source # Instance detailsDefined in NType Source # Instance detailsDefined in NType type IdentityElement (,) = ()

class MonoidOf tensor m where Source #

Minimal complete definition

Methods

mu :: tensor m m -> m Source #

eta :: IdentityElement tensor -> m Source #

Instances
 Source # Instance detailsDefined in NType Methodsmu :: Either m m -> m Source # Monoid m => MonoidOf (,) m Source # Instance detailsDefined in NType Methodsmu :: (m, m) -> 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 detailsDefined 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 detailsDefined 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 detailsDefined in NType Methodscompare :: 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 detailsDefined in NType Methodscompare :: 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 detailsDefined in NType MethodsshowsPrec :: 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 detailsDefined in NType MethodsshowsPrec :: 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

Instances
 KnownSpine ([] :: [k]) Source # Instance detailsDefined in NType Methods KnownSpine xs => KnownSpine (x ': xs :: [k]) Source # Instance detailsDefined in NType MethodsknownSpine :: 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 detailsDefined in NType

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