concat-examples-0.3.0.0: Some examples of compiling to categories
Safe HaskellSafe-Inferred
LanguageHaskell2010

ConCat.StackVM

Description

Stack-based VM as a category, enabling compilation from Haskell.

Synopsis

Documentation

newtype StackFun a b Source #

Constructors

SF (forall z. (a :* z) -> b :* z) 

Instances

Instances details
AssociativePCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

BraidedPCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

Methods

swapP :: Ok2 StackFun a b => StackFun (Prod StackFun a b) (Prod StackFun b a) Source #

BraidedSCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

Category StackFun Source # 
Instance details

Defined in ConCat.StackVM

Associated Types

type Ok StackFun :: Type -> Constraint Source #

Methods

id :: Ok StackFun a => StackFun a a Source #

(.) :: forall b c a. Ok3 StackFun a b c => StackFun b c -> StackFun a b -> StackFun a c Source #

ClosedCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

Methods

apply :: Ok2 StackFun a b => StackFun (Prod StackFun (Exp StackFun a b) a) b Source #

curry :: Ok3 StackFun a b c => StackFun (Prod StackFun a b) c -> StackFun a (Exp StackFun b c) Source #

uncurry :: Ok3 StackFun a b c => StackFun a (Exp StackFun b c) -> StackFun (Prod StackFun a b) c Source #

CoproductCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

DistribCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

MonoidalPCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

Methods

(***) :: Ok4 StackFun a b c d => StackFun a c -> StackFun b d -> StackFun (Prod StackFun a b) (Prod StackFun c d) Source #

first :: forall a a' b. Ok3 StackFun a b a' => StackFun a a' -> StackFun (Prod StackFun a b) (Prod StackFun a' b) Source #

second :: Ok3 StackFun a b b' => StackFun b b' -> StackFun (Prod StackFun a b) (Prod StackFun a b') Source #

MonoidalSCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

Methods

(+++) :: Ok4 StackFun a b c d => StackFun c a -> StackFun d b -> StackFun (Coprod StackFun c d) (Coprod StackFun a b) Source #

left :: forall a a' b. Oks StackFun '[a, b, a'] => StackFun a a' -> StackFun (Coprod StackFun a b) (Coprod StackFun a' b) Source #

right :: Oks StackFun '[a, b, b'] => StackFun b b' -> StackFun (Coprod StackFun a b) (Coprod StackFun a b') Source #

ProductCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

TerminalCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

Methods

it :: Ok StackFun a => StackFun a (Unit StackFun) Source #

UnitCat StackFun Source # 
Instance details

Defined in ConCat.StackVM

type Ok StackFun Source # 
Instance details

Defined in ConCat.StackVM

unSF :: StackFun a b -> forall z. (a :* z) -> b :* z Source #

inSF :: ((forall z. (a :* z) -> b :* z) -> forall z. (c :* z) -> d :* z) -> StackFun a b -> StackFun c d Source #

inSF2 :: ((forall z. (a :* z) -> b :* z) -> (forall z. (c :* z) -> d :* z) -> forall z. (p :* z) -> q :* z) -> StackFun a b -> StackFun c d -> StackFun p q Source #

stackFun :: (a -> b) -> StackFun a b Source #

The semantic functor that specifies StackFun.

evalStackFun :: StackFun a b -> a -> b Source #

data Prim :: * -> * -> * where Source #

Constructors

Swap :: Prim (a :* b) (b :* a) 
Exl :: Prim (a :* b) a 
Exr :: Prim (a :* b) b 
Dup :: Prim a (a :* a) 
Const :: Show b => b -> Prim a b 
Negate :: Num a => Prim a a 
Add, Sub, Mul :: Num a => Prim (a :* a) a 
PowI :: Num a => Prim (a :* Int) a 
(:+++) :: StackOps a c -> StackOps b d -> Prim (a :+ b) (c :+ d) 
Apply :: Prim ((a -> b) :* a) b 
Curry :: StackProg (a :* b) c -> Prim a (b -> c) 

Instances

Instances details
Show (Prim a b) Source # 
Instance details

Defined in ConCat.StackVM

Methods

showsPrec :: Int -> Prim a b -> ShowS Source #

show :: Prim a b -> String Source #

showList :: [Prim a b] -> ShowS Source #

evalPrim :: Prim a b -> a -> b Source #

data StackOp :: * -> * -> * where Source #

Constructors

Pure :: Prim a b -> StackOp (a :* z) (b :* z) 
Push :: StackOp ((a :* b) :* z) (a :* (b :* z)) 
Pop :: StackOp (a :* (b :* z)) ((a :* b) :* z) 

Instances

Instances details
Show2 StackOp Source # 
Instance details

Defined in ConCat.StackVM

Methods

show2 :: forall (a :: k) (b :: k1). StackOp a b -> String Source #

Show (StackOp a b) Source # 
Instance details

Defined in ConCat.StackVM

Methods

showsPrec :: Int -> StackOp a b -> ShowS Source #

show :: StackOp a b -> String Source #

showList :: [StackOp a b] -> ShowS Source #

evalStackOp :: StackOp u v -> u -> v Source #

data StackOps :: * -> * -> * where Source #

Constructors

Nil :: StackOps a a 
(:<) :: StackOp a b -> StackOps b c -> StackOps a c infixr 5 

Instances

Instances details
Show (StackOps a b) Source # 
Instance details

Defined in ConCat.StackVM

toList :: forall z a b. (forall u v. StackOp u v -> z) -> StackOps a b -> [z] Source #

evalStackOps :: StackOps a b -> a -> b Source #

(++*) :: StackOps a b -> StackOps b c -> StackOps a c infixr 5 Source #

data StackProg a b Source #

Constructors

SP 

Fields

Instances

Instances details
AssociativePCat StackProg Source # 
Instance details

Defined in ConCat.StackVM

BraidedPCat StackProg Source # 
Instance details

Defined in ConCat.StackVM

Category StackProg Source # 
Instance details

Defined in ConCat.StackVM

Associated Types

type Ok StackProg :: Type -> Constraint Source #

Methods

id :: Ok StackProg a => StackProg a a Source #

(.) :: forall b c a. Ok3 StackProg a b c => StackProg b c -> StackProg a b -> StackProg a c Source #

ClosedCat StackProg Source # 
Instance details

Defined in ConCat.StackVM

MonoidalPCat StackProg Source # 
Instance details

Defined in ConCat.StackVM

Methods

(***) :: Ok4 StackProg a b c d => StackProg a c -> StackProg b d -> StackProg (Prod StackProg a b) (Prod StackProg c d) Source #

first :: forall a a' b. Ok3 StackProg a b a' => StackProg a a' -> StackProg (Prod StackProg a b) (Prod StackProg a' b) Source #

second :: Ok3 StackProg a b b' => StackProg b b' -> StackProg (Prod StackProg a b) (Prod StackProg a b') Source #

ProductCat StackProg Source # 
Instance details

Defined in ConCat.StackVM

TerminalCat StackProg Source # 
Instance details

Defined in ConCat.StackVM

UnitCat StackProg Source # 
Instance details

Defined in ConCat.StackVM

Show b => ConstCat StackProg b Source # 
Instance details

Defined in ConCat.StackVM

Num a => NumCat StackProg a Source # 
Instance details

Defined in ConCat.StackVM

Show (StackProg a b) Source # 
Instance details

Defined in ConCat.StackVM

type Ok StackProg Source # 
Instance details

Defined in ConCat.StackVM

evalProg :: StackProg a b -> a -> b Source #

data Exists2 k Source #

Constructors

forall a b. Exists2 (a `k` b) 

Instances

Instances details
Show2 k => Show (Exists2 k) Source # 
Instance details

Defined in ConCat.StackVM