caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Carette <carette@mcmaster.ca>
To: Pietro Abate <Pietro.Abate@anu.edu.au>, caml-list@inria.fr
Subject: Re: [Caml-list] Re: (continuation monad) type problem...
Date: Fri, 14 Jul 2006 12:41:22 -0400	[thread overview]
Message-ID: <44B7C932.8020501@mcmaster.ca> (raw)
In-Reply-To: <20060713070848.GA3885@pulp.rsise.anu.edu.au>

It seems that a small modification to the definition of ContT can 
restore polymophism:

module ContT (M : Monad) = struct
  type res = unit
  type ('a,'b) k = Cont of (('a -> 'b m) -> 'b m)
  and 'a m = (res * ('a,res) k M.m) M.m

  let return a = Cont (fun c -> c a)
  let bind m k = Cont (fun c ->
    let (Cont m')  = m   in m' (fun a ->
    let (Cont ka') = k a in ka' c))
end;;

The main change is that to have 2 type parameters in your 
continuation.   Also note that while 'a m is defined in terms of res (ie 
unit) for its second parameter, we know this doesn't matter (since 
continuations never really "return"), and thus ocaml is able to infer a 
polymorphic type for bind:

val bind : ('a, 'b) k -> ('a -> ('c, 'b) k) -> ('c, 'b) k

Jacques


      reply	other threads:[~2006-07-14 16:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-12  8:40 oleg
2006-07-13  7:08 ` Pietro Abate
2006-07-14 16:41   ` Jacques Carette [this message]

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=44B7C932.8020501@mcmaster.ca \
    --to=carette@mcmaster.ca \
    --cc=Pietro.Abate@anu.edu.au \
    --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).