Polysemy: Introduction to Effect definitionGautier DI FOLCO December 07, 2022 [Haskell] #haskell #polysemy #design #effects systems
In the first log we explained that in the expression:
= do trace $ "Displaying " <> path content <- embed $ readFile path embed $ putStr content return $ length content displayFile path
trace is emiting an effect of
trace has the following type:
and is generated via:
data Trace (m :: Type -> Type) a where Trace :: String -> Trace m () makeSem ''Trace
makeSem will generate something like:
= emit $ Trace a trace a
trace is called, the value is sent to the interpreter.
Note: to keep it short
m will be replaced by
Sem r during interpretation
See the full the code here.