[Haskell-beginners] Relation between Effects, Indexed monads, Free monads

PY aquagnu at gmail.com
Wed Nov 15 12:15:13 UTC 2017


Hello, All!

I'm not sure is it question for Cafe or Beginners List, so first I'll 
try here.

There are kind of errors related to wrong execution sequence. They are 
good known in OOP: object keeps state internally and check it before to 
execute got message - to prevent wrong execution sequence. Best 
implementation is: state machine, also can be used Markov's algorithm, 
more complex can be done with Petri nets, etc.

Example: if I have complex inserting into DB (consisting of several 
inserts), I can check done of previous step before to start next, etc. 
After read of different Haskell resources I found solution for it: 
Indexed Monads. They (if I got it rightly) are monads with additional 
type parameter which "marks" monad, gives it more specific 
qualification, for example instead of monad "Opening" (action) we have 
monad "Opening-of-closed", exactly what I'm talking: type-level check of 
correct actions sequence (allowed transition).

After more research I found Free Monads and Effects and something like  
"free monad can be used to proof your program". How?! Free monads  make 
"active" (executable) code into "passive" code (data instead of code), 
which can be interpreted separately, so program becomes like Lisp 
program: code is a data (so, can be modified, checked, etc, etc) and 
what exactly will be executing - decides interpreter of such code. But 
do they allow to proof right sequence of actions in such data-like code?

What are the Effects I don't understand yet.

Somewhere I find something like: Eff = Free Monad + indexed monad (may 
be I'm not right here). So  my questions are:

- how Effects, Free Monad, Indexed Monads are related?

- can effects replace indexed monads?

- are indexed monad yet usable/modern concept or they are abandoned and 
replaced by Effects or something else? Do you use indexed monads in real 
projects?

- can I (and how) to use both of them? Or: can I use only FreeMonads / 
Effects to solve the same problem (control of correct sequence of 
actions) like with indexed monads help?


===

Best regards, Paul



More information about the Beginners mailing list