<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><span id="result_box" class="short_text" lang="en"><span class="">Hello,
          Toz,</span></span></p>
    <p><span id="result_box" class="short_text" lang="en"><span class="">I
          apologize for my little bit confused question. The root of my
          interest to such approaches is the situation when order is not
          possible to be done in one code fragment (such function under
          monad) because "ordered" steps should happens not immediately
          one after one, but with time gap, possible in different
          location of the program. For example, if you do:</span></span></p>
    <ol>
      <li><span id="result_box" class="short_text" lang="en"><span
            class="">open file</span></span></li>
      <li><span id="result_box" class="short_text" lang="en"><span
            class="">read data</span></span></li>
      <li><span id="result_box" class="short_text" lang="en"><span
            class="">close file</span></span></li>
    </ol>
    <p><span id="result_box" class="short_text" lang="en"><span class="">all
          these actions are ordered and are located on time axis near
          one to one, happening immediately. But another case can be:</span></span></p>
    <ol>
      <li><span id="result_box" class="short_text" lang="en"><span
            class="">insert info about class rooms</span></span></li>
      <li><span id="result_box" class="short_text" lang="en"><span
            class="">do different things (may be exit application even)<br>
          </span></span></li>
      <li><span id="result_box" class="short_text" lang="en"><span
            class="">insert info about pupils</span></span></li>
    </ol>
    <p><span id="result_box" class="short_text" lang="en"><span class="">It's
        </span></span><span id="result_box" class="short_text" lang="en"><span
          class=""><span id="result_box" class="short_text" lang="en"><span
              class="">fictitious example and is targeting by RDBMS but
              this example is only to illustrate what I'm talking about.
              I found good example on SO with DVD control:
              <a class="moz-txt-link-freetext" href="https://stackoverflow.com/questions/28690448/what-is-indexed-monad">https://stackoverflow.com/questions/28690448/what-is-indexed-monad</a></span></span></span></span></p>
    Also I found that indexed monads can be used to change type of the
    state "on the fly". So, for me, it's interesting to control allowed
    transitions between monad actions:<br>
    <br>
    <blockquote><tt>do</tt><br>
      <tt>  action1</tt><br>
      <tt>  action2</tt><br>
      <tt>  -- action3 is denied because "action2 => action3" is
        denied transition/sequence</tt><br>
    </blockquote>
    And I'm agree with you that Eff + Free monads looks different from
    this goal. But I found somewhere that Free monad can be used as
    proof assistance (there was some lecture on Youtube in Ljubljana
    university, but I can't find it more) and I'm thinking: may be it's
    possible to use Free monads for something similar like indexed
    monads? I found indexed free monads but such abstraction looks very
    complex and hard to me.<br>
    <br>
    ===<br>
    Best regards, Paul<br>
    <br>
    <br>
    <div class="moz-cite-prefix">16.11.2017 04:29, 鲍凯文 wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAMjcG+GxtyOKCMkCzx=SqDBk-Q1jGye1KsDC2P+PqjsOGFP5Nw@mail.gmail.com">
      <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" moz-do-not-send="true">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"
                    moz-do-not-send="true">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"
                    moz-do-not-send="true">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"
                    moz-do-not-send="true">beginners-request@haskell.org</a><br>
                  <br>
                  You can reach the person managing the list at<br>
                          <a href="mailto:beginners-owner@haskell.org"
                    moz-do-not-send="true">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"
                    moz-do-not-send="true">aquagnu@gmail.com</a>><br>
                  To: <a href="mailto:beginners@haskell.org"
                    moz-do-not-send="true">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"
                    moz-do-not-send="true">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"
                    moz-do-not-send="true">Beginners@haskell.org</a><br>
                  <a
                    href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true">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>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>