graninas/The-Amoeba-World

Eval type safety

graninas opened this issue · 1 comments

mprove types for type safety:

type EvalType a b = State a b
type Eval a = EvalType EvaluationContext a
type ObjectedEval a = Eval a

It should allow using 'read prop' only in functions with type ObjectedEval a:
produce :: ObjectedEval ()
produce = do
f <- read fabric
pl <- read ownership
k <- find
return ()

But this variant should be impossible to compile:

run :: Eval ScenarioResult
run = do
with fabric produce
f <- read fabric
example

Type safety elaborated in a different way. It is now the monad stack 'EitherT EvalError (State ctx) res'.