caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: oleg@pobox.com
To: caml-list@inria.fr
Subject: Re: (continuation monad) type problem...
Date: Wed, 19 Jul 2006 18:22:50 -0700 (PDT)	[thread overview]
Message-ID: <20060720012250.9E633A9B4@Adric.metnet.fnmoc.navy.mil> (raw)


Pietro Abate wrote:
> but ContT is not a monad as the type inferred for bind is not
> polymorphic : bind : 'a k -> ('a -> 'a k) -> 'a k
> And I think this is true in general as soon as I define a monad type
> recursively. 

That polymorphism problem is inherent; to avoid it we need to add
extra parameters to our continuation (as Jacques Carette pointed
out), or do something else. Namely, turn to delimited continuations
with multiple prompts. Truly undelimited continuations are hardly ever
called for. Multi-prompt delimited continuations are strictly more
expressive; they also have clear operational and denotational
semantics. The latter is the consequence of CPS transforms.  Also,
multi-prompt delimited continuations have no typing problems and they
are available in the CC monad, which is truly a monad with no
reservations.

	http://www.cas.mcmaster.ca/~carette/pa_monad/
	http://www.cas.mcmaster.ca/~carette/pa_monad/test-cc.ml


> The point of the ContListM is to capture a list of computations ('a m),
> where each element (res * 'a k M.m) has the result of the computation up
> to a certain point (res in the example) and the list of all the
> continuations on that branch ('a k M.m). Each element of the list ('a m)
> corresponds to a computation branch. The idea is to create a fsa that
> stops at each state, asks for new input and resumes the computation
> following an external procedure.  Alternation in the fsa gives the need
> to have an outer monad list to account different possible
> branches/computations that the fsa can choose. 

I'm afraid I could not understand the problem. Why the conventional
FSA implementations won't work? I should point out that the
phrase ``result of the computation up to a certain point'' is
evocative of delimited continuations. Incidentally, delimited
continuations can be used to realize the LogicT monad (transformer,
actually) -- which is MonadPlus with additional operations supporting
a `look-ahead' in a non-deterministic computation. The latter is
needed to implement committed choice and "don't care"
nondeterminism. The implementation indeed maintains the tree of
continuations (each `mplus' builds a fork). The current
implementation is in Haskell
	http://pobox.com/~oleg/ftp/Computation/monads.html#LogicT
but it can be quite easily ported to OCaml, now that CC monad is
available here too.




             reply	other threads:[~2006-07-20  1:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-20  1:22 oleg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-07-12  8:40 oleg
2006-07-13  7:08 ` Pietro Abate

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060720012250.9E633A9B4@Adric.metnet.fnmoc.navy.mil \
    --to=oleg@pobox.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).