proarrow
Safe HaskellNone
LanguageGHC2024

Proarrow.Category.Instance.Simulator

Description

Clocked state machines. Each step consumes one input and produces one output and the next machine. Composition and tensor advance every component once per clock cycle.

>>> runSimulator (stateless not) [False, True]
[True,False]
>>> runSimulator (stateless (+ 1) . stateless (* 2)) [1 :: Int, 2]
[3,5]
Synopsis

Documentation

data SIMULATOR Source Github #

Constructors

Sim Type 

Instances

Instances details
Monoidal SIMULATOR Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Associated Types

type Unit 
Instance details

Defined in Proarrow.Category.Instance.Simulator

type Unit = 'Sim ()
type (a :: SIMULATOR) ** (b :: SIMULATOR) 
Instance details

Defined in Proarrow.Category.Instance.Simulator

type (a :: SIMULATOR) ** (b :: SIMULATOR) = 'Sim (UN 'Sim a, UN 'Sim b)

Methods

withOb2 :: forall (a :: SIMULATOR) (b :: SIMULATOR) r. (Ob a, Ob b) => (Ob (a ** b) => r) -> r Source Github #

leftUnitor :: forall (a :: SIMULATOR). Ob a => ((Unit :: SIMULATOR) ** a) ~> a Source Github #

leftUnitorInv :: forall (a :: SIMULATOR). Ob a => a ~> ((Unit :: SIMULATOR) ** a) Source Github #

rightUnitor :: forall (a :: SIMULATOR). Ob a => (a ** (Unit :: SIMULATOR)) ~> a Source Github #

rightUnitorInv :: forall (a :: SIMULATOR). Ob a => a ~> (a ** (Unit :: SIMULATOR)) Source Github #

associator :: forall (a :: SIMULATOR) (b :: SIMULATOR) (c :: SIMULATOR). (Ob a, Ob b, Ob c) => ((a ** b) ** c) ~> (a ** (b ** c)) Source Github #

associatorInv :: forall (a :: SIMULATOR) (b :: SIMULATOR) (c :: SIMULATOR). (Ob a, Ob b, Ob c) => (a ** (b ** c)) ~> ((a ** b) ** c) Source Github #

SymMonoidal SIMULATOR Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

swap :: forall (a :: SIMULATOR) (b :: SIMULATOR). (Ob a, Ob b) => (a ** b) ~> (b ** a) Source Github #

CopyDiscard SIMULATOR Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

copy :: forall (a :: SIMULATOR). Ob a => a ~> (a ** a) Source Github #

discard :: forall (a :: SIMULATOR). Ob a => a ~> (Unit :: SIMULATOR) Source Github #

CategoryOf SIMULATOR Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Associated Types

type (~>) 
Instance details

Defined in Proarrow.Category.Instance.Simulator

type Ob (a :: SIMULATOR) 
Instance details

Defined in Proarrow.Category.Instance.Simulator

type Ob (a :: SIMULATOR) = Is 'Sim a
Promonad Simulator Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

id :: forall (a :: SIMULATOR). Ob a => Simulator a a Source Github #

(.) :: forall (b :: SIMULATOR) (c :: SIMULATOR) (a :: SIMULATOR). Simulator b c -> Simulator a b -> Simulator a c Source Github #

Ob a => CocommutativeComonoid (a :: SIMULATOR) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Ob a => Comonoid (a :: SIMULATOR) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

counit :: a ~> (Unit :: SIMULATOR) Source Github #

comult :: a ~> (a ** a) Source Github #

MonoidalProfunctor Simulator Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

one :: Simulator (Unit :: SIMULATOR) (Unit :: SIMULATOR) Source Github #

(**) :: forall (x1 :: SIMULATOR) (x2 :: SIMULATOR) (y1 :: SIMULATOR) (y2 :: SIMULATOR). Simulator x1 x2 -> Simulator y1 y2 -> Simulator (x1 ** y1) (x2 ** y2) Source Github #

Profunctor Simulator Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

dimap :: forall (c :: SIMULATOR) (a :: SIMULATOR) (b :: SIMULATOR) (d :: SIMULATOR). (c ~> a) -> (b ~> d) -> Simulator a b -> Simulator c d Source Github #

lmap :: forall (c :: SIMULATOR) (a :: SIMULATOR) (b :: SIMULATOR). (c ~> a) -> Simulator a b -> Simulator c b Source Github #

rmap :: forall (b :: SIMULATOR) (d :: SIMULATOR) (a :: SIMULATOR). (b ~> d) -> Simulator a b -> Simulator a d Source Github #

(\\) :: forall (a :: SIMULATOR) (b :: SIMULATOR) r. ((Ob a, Ob b) => r) -> Simulator a b -> r Source Github #

FunctorForRep Value Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Circuit

Associated Types

type Value @ ('Ready 'Bit) 
Instance details

Defined in Proarrow.Category.Instance.Circuit

type Value @ ('Ready 'Bit) = 'Sim Bool
type Value @ ('Ready 'Empty) 
Instance details

Defined in Proarrow.Category.Instance.Circuit

type Value @ ('Ready 'Empty) = 'Sim ()
type Value @ ('Ready ('Pair a b) :: PREPARED) 
Instance details

Defined in Proarrow.Category.Instance.Circuit

type Value @ ('Ready ('Pair a b) :: PREPARED) = 'Sim (Sample a, Sample b)

Methods

fmap :: forall (a :: PREPARED) (b :: PREPARED). (a ~> b) -> (Value @ a) ~> (Value @ b) Source Github #

MonoidalProfunctor (Rep Value) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Circuit

Methods

one :: Rep Value (Unit :: SIMULATOR) (Unit :: PREPARED) Source Github #

(**) :: forall (x1 :: SIMULATOR) (x2 :: PREPARED) (y1 :: SIMULATOR) (y2 :: PREPARED). Rep Value x1 x2 -> Rep Value y1 y2 -> Rep Value (x1 ** y1) (x2 ** y2) Source Github #

type Unit Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

type Unit = 'Sim ()
type (~>) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

type Ob (a :: SIMULATOR) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

type Ob (a :: SIMULATOR) = Is 'Sim a
type (a :: SIMULATOR) ** (b :: SIMULATOR) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

type (a :: SIMULATOR) ** (b :: SIMULATOR) = 'Sim (UN 'Sim a, UN 'Sim b)
type Value @ ('Ready 'Bit) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Circuit

type Value @ ('Ready 'Bit) = 'Sim Bool
type Value @ ('Ready 'Empty) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Circuit

type Value @ ('Ready 'Empty) = 'Sim ()
type Value @ ('Ready ('Pair a b) :: PREPARED) Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Circuit

type Value @ ('Ready ('Pair a b) :: PREPARED) = 'Sim (Sample a, Sample b)

data Simulator (a :: SIMULATOR) (b :: SIMULATOR) where Source Github #

A machine and its current state, represented by its next step.

Constructors

Simulator :: forall a1 b1. (a1 -> (b1, Simulator ('Sim a1) ('Sim b1))) -> Simulator ('Sim a1) ('Sim b1) 

Instances

Instances details
Promonad Simulator Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

id :: forall (a :: SIMULATOR). Ob a => Simulator a a Source Github #

(.) :: forall (b :: SIMULATOR) (c :: SIMULATOR) (a :: SIMULATOR). Simulator b c -> Simulator a b -> Simulator a c Source Github #

MonoidalProfunctor Simulator Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

one :: Simulator (Unit :: SIMULATOR) (Unit :: SIMULATOR) Source Github #

(**) :: forall (x1 :: SIMULATOR) (x2 :: SIMULATOR) (y1 :: SIMULATOR) (y2 :: SIMULATOR). Simulator x1 x2 -> Simulator y1 y2 -> Simulator (x1 ** y1) (x2 ** y2) Source Github #

Profunctor Simulator Source Github # 
Instance details

Defined in Proarrow.Category.Instance.Simulator

Methods

dimap :: forall (c :: SIMULATOR) (a :: SIMULATOR) (b :: SIMULATOR) (d :: SIMULATOR). (c ~> a) -> (b ~> d) -> Simulator a b -> Simulator c d Source Github #

lmap :: forall (c :: SIMULATOR) (a :: SIMULATOR) (b :: SIMULATOR). (c ~> a) -> Simulator a b -> Simulator c b Source Github #

rmap :: forall (b :: SIMULATOR) (d :: SIMULATOR) (a :: SIMULATOR). (b ~> d) -> Simulator a b -> Simulator a d Source Github #

(\\) :: forall (a :: SIMULATOR) (b :: SIMULATOR) r. ((Ob a, Ob b) => r) -> Simulator a b -> r Source Github #

stateless :: (a -> b) -> Simulator ('Sim a) ('Sim b) Source Github #

Apply a function independently in every clock cycle.

step :: Simulator ('Sim a) ('Sim b) -> a -> (b, Simulator ('Sim a) ('Sim b)) Source Github #

Observe the current output and advance one clock cycle.

runSimulator :: Simulator ('Sim a) ('Sim b) -> [a] -> [b] Source Github #

Run a sequence of inputs, starting from the machine's current state.