caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Carette <carette@mcmaster.ca>
To: Andreas Rossberg <AndreasRossberg@web.de>
Cc: caml-list@inria.fr
Subject: How do I achiece this, was Re: [Caml-list] Variance problem in higher-order Functors?
Date: Tue, 25 Jul 2006 16:45:20 -0400	[thread overview]
Message-ID: <44C682E0.6040805@mcmaster.ca> (raw)
In-Reply-To: <00ea01c6ae9d$3c459750$15b2a8c0@wiko>

My real question is (and should have been), how do I translate

module type DOMAIN = sig type kind end
type domain_is_field
type domain_is_ring
module Rational = struct type kind = domain_is_field end
module Integer = struct type kind = domain_is_ring end

module DivisionUpdate(D:DOMAIN with type kind = domain_is_field) = struct
  (* something only valid with D a field*)
end

module GeneralUpdate(D:DOMAIN) = struct
   (* something that always works, for rings and fields *)
end

The behaviour I want should be the same as the first-order applications
module A = DivisionUpdate(Rational)  (* OK *)
module B = GeneralUpdate(Rational)  (* OK *)
module C = DivisionUpdate(Integer)  (* ERROR *)
module D = GeneralUpdate(Integer)  (* OK *)
BUT I want to pass all these modules as parameters to a functor.  I 
don't see how to build the proper type that will work!
[I have read the manuals in depth, Googled around the caml.inria.fr web 
site, played around with the implementation, etc to no avail]

In other words, I want to be able to define
module type Trans = functor(U:UPDATE) ->  functor(D:DOMAIN) -> sig ... end
but none of my attempts have worked, even though the first-order code 
works fine.

I would be happy with a solution that uses polymorphic variants, or 
objects, or whatever work.  The only thing I can't do is "run-time" 
tests, as I have a dozen domains, with more functors and more 
constraints floating around, so I really want this to be a type-level 
solution.  If OCaml had conditional module application, I could use 
that, but "expanding" my definitions is not realistic.

Jacques


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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-23 19:58 Jacques Carette
2006-07-23 21:16 ` [Caml-list] " Andreas Rossberg
2006-07-25 20:45   ` Jacques Carette [this message]
2006-07-26  5:16     ` How do I achiece this, was " 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=44C682E0.6040805@mcmaster.ca \
    --to=carette@mcmaster.ca \
    --cc=AndreasRossberg@web.de \
    --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).