From: Pietro Abate <Pietro.Abate@anu.edu.au>
To: ocaml ml <caml-list@inria.fr>
Subject: type problem...
Date: Wed, 12 Jul 2006 12:12:09 +1000 [thread overview]
Message-ID: <20060712021209.GA21404@pulp.rsise.anu.edu.au> (raw)
Hi all,
I'm trying to type-check the continuation monad defined as follows:
module LM =
struct
type 'a m = 'a list
let return x = [x]
let mzero = []
let bind m f = List.flatten (List.map f m)
let mplus = List.append
let guard b = if b then return () else mzero
end
;;
module CM
: sig
type r
type 'node k = (('node -> 'node m) -> 'node m)
and 'node m = (r * 'node k LM.m) LM.m
val return : 'a -> 'a k
val bind : 'a k -> ('a -> 'b k) -> 'b k
val callCC : (('a -> 'b k) -> 'a k) -> 'a k
end
= struct
type r
type 'node k = (('node -> 'node m) -> 'node m)
and 'node m = (r * 'node k LM.m) LM.m
let return a = (fun k -> k a)
let bind m f = (fun k -> m (fun x -> f x k))
let callCC f k1 = ( f (fun x k2 -> k1 x) k1 )
end
if you compile it with ocamlc -rectypes -i ex.ml the compile says:
Values do not match:
val bind : (('a -> 'b) -> 'c) -> ('a -> 'd -> 'b) -> 'd -> 'c
is not included in
val bind : 'a k -> ('a -> 'b k) -> 'b k
but at first sight, these two types should match ... maybe not ...
or at least they do match if the type k is not cyclic...
I think the solution is in Wadler paper
http://portal.acm.org/citation.cfm?id=143169 in section 3.3, but it is not
entirely clear what I should do here ... to get the right type...
--
++ Blog: http://blog.rsise.anu.edu.au/?q=pietro
++
++ "All great truths begin as blasphemies." -George Bernard Shaw
++ Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
reply other threads:[~2006-07-12 2:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20060712021209.GA21404@pulp.rsise.anu.edu.au \
--to=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