| Portability | unportable |
|---|---|
| Stability | experimental |
| Maintainer | jochem@functor.nl |
Control.Hasim.Process
Description
This module takes care of defining processes and their actions.
- data Proc pkt st = Proc {}
- type Acceptor pkt st = pkt -> AcceptResult pkt st
- data Process = forall pkt st . Process (Proc pkt st)
- data PrimAction where
- Ret :: a -> PrimAction pkt st a
- Wait :: Time -> PrimAction pkt st ()
- Send :: snd -> Proc snd st2 -> Time -> PrimAction pkt st Bool
- Unwatch :: Proc rcv st2 -> PrimAction pkt st ()
- WithAcceptor :: Acceptor pkt st -> Action pkt st () -> PrimAction pkt st ()
- PopAcceptor :: PrimAction pkt st ()
- PerformIO :: IO a -> PrimAction pkt st a
- ObserveTime :: PrimAction pkt st Time
- GetState :: PrimAction pkt st st
- PutState :: st -> PrimAction pkt st ()
- WaitForever :: PrimAction pkt st ()
- data Action where
- Prim :: PrimAction pkt st a -> Action pkt st a
- data Atom = forall a st pkt . Atom (PrimAction pkt st a)
- data Runnable = forall a pkt st . Run (Proc pkt st) (PrimAction pkt st a) (Maybe (a -> Runnable))
- runnable2process :: Runnable -> Process
- toRunnable :: Proc pkt st -> Action pkt st () -> Runnable
- data AcceptResult pkt st
Documentation
A Proc st pkt is a process that potentially accepts packets of type
pkt while maintaining state st.
Constructors
| Proc | |
Fields
| |
type Acceptor pkt st = pkt -> AcceptResult pkt stSource
An acceptor of a pkt is an AcceptResult, which is either
* Refuse if the packet is to be delivered at a later time, or
never, of course
* Parallel act if a current computation should not be suspended,
but the state should be changed.
* Interrupt act if the current computation should be suspended.
data PrimAction whereSource
GADT for the primitive actions. These are the primitives Hasim supports.
A PrimAction pkt st a is a primitive action where
* pkt is the packet type the associated Proc supports.
* st is the state of the associated Proc.
* a is the return type of the PrimAction.
(this is why we need a GADT; the return type
varies for each primitive action).
(Unfortunately, the documentation for each constructor is not available in the generated output due to a glitch in Haddock. You can use the source, which is documented.)
Constructors
| Ret :: a -> PrimAction pkt st a | |
| Wait :: Time -> PrimAction pkt st () | |
| Send :: snd -> Proc snd st2 -> Time -> PrimAction pkt st Bool | |
| Unwatch :: Proc rcv st2 -> PrimAction pkt st () | |
| WithAcceptor :: Acceptor pkt st -> Action pkt st () -> PrimAction pkt st () | |
| PopAcceptor :: PrimAction pkt st () | |
| PerformIO :: IO a -> PrimAction pkt st a | |
| ObserveTime :: PrimAction pkt st Time | |
| GetState :: PrimAction pkt st st | |
| PutState :: st -> PrimAction pkt st () | |
| WaitForever :: PrimAction pkt st () |
Instances
| Show (PrimAction pkt st a) |
The Action GADT. This is a GADT with three
parameters; an Action pkt st a is a action where
* pkt denotes the packet type of incoming packets
* st denotes the state that can be modified
and inspected
* a denotes the result value of the Action
Constructors
| Prim :: PrimAction pkt st a -> Action pkt st a |
Existential type for the PrimAction type.
Constructors
| forall a st pkt . Atom (PrimAction pkt st a) |
A Runnable is an action that can be run. A Runnable has
three parameters:
* The first is the process to which this Runnable belongs.
* The second is a primitive action to be run.
* The third is Maybe a continuation.
Constructors
| forall a pkt st . Run (Proc pkt st) (PrimAction pkt st a) (Maybe (a -> Runnable)) |