From: Jacques Carette <carette@mcmaster.ca>
To: caml-list@inria.fr
Subject: How do I abstract out polymorphic variants via functors?
Date: Fri, 18 Aug 2006 09:35:34 -0400 [thread overview]
Message-ID: <44E5C226.3030802@mcmaster.ca> (raw)
I have 3 module types, each of which start out "the same", viz:
module type DETERMINANT = sig
type 'a lstate
type 'a tag_lstate = [`TDet of 'a lstate ]
type ('b,'v) lm = ('a,'v,'s,'w) cmonad
constraint 's = [> 'a tag_lstate]
constraint 'b = 'a * 's * 'w
...
end
module type RANK = sig
type 'a lstate = ('a, int ref) code
type 'a tag_lstate = [`TRan of 'a lstate ]
type ('b,'v) lm = ('a,'v,'s,'w) cmonad
constraint 's = [> 'a tag_lstate]
constraint 'b = 'a * 's * 'w
...
end
module type TRACKPIVOT = sig
type 'a lstate
type 'a tag_lstate = [`TPivot of 'a lstate ]
type ('b,'v) lm = ('a,'v,'s,'w) cmonad
constraint 's = [> 'a tag_lstate]
constraint 'b = 'a * 's * 'w
...
end
[I realize that I will have to lose the RANK type's definition of 'a
lstate when I abstract this out]
The only thing different between those 3 is the name of the polymorphic
variant - so clearly an opportunity for abstraction! But I can't seem
to achieve this. Is there a way?
Jacques
next reply other threads:[~2006-08-18 14:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-18 13:35 Jacques Carette [this message]
2006-08-19 14:51 ` [Caml-list] " Jacques Garrigue
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=44E5C226.3030802@mcmaster.ca \
--to=carette@mcmaster.ca \
--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