<div dir="ltr">Hi,<div><br></div><div>Disclaimer: I am not a lawyer. Nor do I claim to understand all this stuff.</div><div><br></div><div>The enforcement of sequential ordering is sort of baked into monads; the haskell (read: do-notation) way of combining monadic computations is using bind (i.e. in the "fancy list of instructions with a way to bind results"). This is only for the structure of the computation, though. Every monadic computation is still a pure function, so in the end the RTS, well, executes parts of those at a time, just as pure functions.</div><div><br></div><div>The ordering guarantee that more corresponds to imperative programming is most obvious (to me) with ST, IO, and State; data dependencies ensure that things "later" in the monadic chain cannot be executed until everything "before". But those effects all involve (mutable) state. Monadic chaining, i.e. combining effectful computations, is separate from the concept of mutable state, etc. It seems more like just an algebra for effects.</div><div><br></div><div>If you're talking about marked monads as in those with extra type information or phantom params, like when used in tandem with the rank-2 type trick (used in ST, region-based IO, etc.), I think that's a little different, or at least beyond what monads are. Those were created to handle things like guaranteeing that state is only modified single-threadedly (ST), or to ensure that you can't do things like forget to close a handle or leak a ref to a closed one (regions).</div><div><br></div><div>I think Free monads and (Kiselyov's) Eff monad are still different. They still appeal to the "monads as sequence of instructions" view, but uh, especially with the Eff monad, they're pretty fancy. As in at least personally, for "normal" programming, I haven't felt the need to delve into them.</div><div><br></div><div>I think the important upshot is: what are you working on? Do monadic computations model what you want to do naturally? If they do, do you need something stronger than what they provide? It's hard to answer the latter questions without answering the first.</div><div><br></div><div>Sorry for rambling,</div><div><br></div><div>toz</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 15, 2017 at 4:00 AM, <span dir="ltr"><<a href="mailto:beginners-request@haskell.org" target="_blank">beginners-request@haskell.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Beginners mailing list submissions to<br>
<a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:beginners-owner@haskell.org">beginners-owner@haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Beginners digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Relation between Effects, Indexed monads, Free monads (PY)<br>
<br>
<br>
------------------------------<wbr>------------------------------<wbr>----------<br>
<br>
Message: 1<br>
Date: Wed, 15 Nov 2017 14:15:13 +0200<br>
From: PY <<a href="mailto:aquagnu@gmail.com">aquagnu@gmail.com</a>><br>
To: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
Subject: [Haskell-beginners] Relation between Effects, Indexed monads,<br>
Free monads<br>
Message-ID: <<a href="mailto:f34c805e-bad4-845e-d09b-43d9a9baea13@gmail.com">f34c805e-bad4-845e-d09b-<wbr>43d9a9baea13@gmail.com</a>><br>
Content-Type: text/plain; charset=utf-8; format=flowed<br>
<br>
Hello, All!<br>
<br>
I'm not sure is it question for Cafe or Beginners List, so first I'll<br>
try here.<br>
<br>
There are kind of errors related to wrong execution sequence. They are<br>
good known in OOP: object keeps state internally and check it before to<br>
execute got message - to prevent wrong execution sequence. Best<br>
implementation is: state machine, also can be used Markov's algorithm,<br>
more complex can be done with Petri nets, etc.<br>
<br>
Example: if I have complex inserting into DB (consisting of several<br>
inserts), I can check done of previous step before to start next, etc.<br>
After read of different Haskell resources I found solution for it:<br>
Indexed Monads. They (if I got it rightly) are monads with additional<br>
type parameter which "marks" monad, gives it more specific<br>
qualification, for example instead of monad "Opening" (action) we have<br>
monad "Opening-of-closed", exactly what I'm talking: type-level check of<br>
correct actions sequence (allowed transition).<br>
<br>
After more research I found Free Monads and Effects and something like <br>
"free monad can be used to proof your program". How?! Free monads make<br>
"active" (executable) code into "passive" code (data instead of code),<br>
which can be interpreted separately, so program becomes like Lisp<br>
program: code is a data (so, can be modified, checked, etc, etc) and<br>
what exactly will be executing - decides interpreter of such code. But<br>
do they allow to proof right sequence of actions in such data-like code?<br>
<br>
What are the Effects I don't understand yet.<br>
<br>
Somewhere I find something like: Eff = Free Monad + indexed monad (may<br>
be I'm not right here). So my questions are:<br>
<br>
- how Effects, Free Monad, Indexed Monads are related?<br>
<br>
- can effects replace indexed monads?<br>
<br>
- are indexed monad yet usable/modern concept or they are abandoned and<br>
replaced by Effects or something else? Do you use indexed monads in real<br>
projects?<br>
<br>
- can I (and how) to use both of them? Or: can I use only FreeMonads /<br>
Effects to solve the same problem (control of correct sequence of<br>
actions) like with indexed monads help?<br>
<br>
<br>
===<br>
<br>
Best regards, Paul<br>
<br>
<br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
______________________________<wbr>_________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/beginners</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Beginners Digest, Vol 113, Issue 10<br>
******************************<wbr>************<br>
</blockquote></div><br></div></div></div></div>