Wiki page
[Actions and Effects] by
neilmadden
2015-07-12 00:08:30.
D 2015-07-12T00:08:30.584
L Actions\sand\sEffects
N text/x-markdown
U neilmadden
W 1204
# Actions and Effects
All side-effects in SiCL occur via Actions. Rather than being executed directly, a side-effecting function builds a description of the actions to be performed as an Action object and returns it. This is similar to the IO monad in Haskell, but I haven't decided whether it will actually be a monad (probably, yes).
Each action is represented by a value of type Action:
type a e Action
Where 'a' is the type of value returned by the action, and e is the type of side-effect it may have. Some example side-effects are:
* NonTermination - may not return at all
* NonDeterministic - may produce different results on each call/may return more than once...
* Input - reads input from some device
* Output - writes output to some device
* ...
These can be combined as variants: (NonDeterministic \| Input)
(Need to think about whether tracking these effects is really that useful).
Almost all actions result from sending messages to agents, using the (<-) operator:
val (<-) : m Agent -> a m -> a Action
i.e., given an agent that accepts messages of polymorphic type m, and a message of type 'a m' it returns an action to produce a value of type a.
Z c46245ed50dcb597b197e8202b54cc86