Polysemy: Introduction to interpretersGautier DI FOLCO November 27, 2022 [Haskell] #haskell #polysemy #design #effects systems
As seen in the previous log we have an expression as follows:
= do trace $ "Displaying " <> path content <- embed $ readFile path embed $ putStr content return $ length content displayFile path
In order to do something useful we need to interpret them in term of
= runM . traceToStdout intrDisplayFile
It can be read that way:
Trace(after the application we have
Sem '[Embed IO] a)
One of the benefit of effects systems is to be able to change the behavior (via the interpretation) without changing the expression.
Trace could be:
- Redirected to
- Redirected to a
- Dropped with
- Accumulated with
See the full the code here.