caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Arnaud Spiwack <arnaud@spiwack.net>
To: Leo White <lpw25@cam.ac.uk>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] Manipulating Modules Modularly
Date: Wed, 22 Oct 2014 11:51:11 +0200	[thread overview]
Message-ID: <CAMoPVjeqUt0HzBcJa5mh84PxFF7JEmEb5Gyd6hQexFzqEcRWpA@mail.gmail.com> (raw)
In-Reply-To: <86fveho4p1.fsf@cam.ac.uk>

[-- Attachment #1: Type: text/plain, Size: 1964 bytes --]

> Depends which issue you mean.
>

I mean having a functor which compiles with several signatures and wanting
to leverage that fact with minimal fuss. But obviously, it does not seem to
stir the passions of the ocaml list readers. I'm going for weird…


> Note that your problem can also be worked around for a fixed number of
> type parameters by defining your module types as:
>
>     module type M = sig
>         type 'a t
>         val u : 'a t
>         val p : 'a t -> 'a t -> 'a t
>       end
>
>     module type ME = sig
>        type 'a t
>        val ps: 'a t list -> 'a t
>     end
>
> which will now work for types with 0 or 1 parameters.
>

It's not very modular, but indeed. It requires signature duplication
however, because (for some reason), we cannot do things like "S with type
'a t := int", and I happen to use substitution. I guess I could use more
powerful ways to manipulate signatures. Like taking a module signature with
a type [t], and turn it into the same signature of type ['a t] (with 'a
universally bound at each function). This is always well defined, isn't it?

The other way around sound easier to do however (replacing a Signature on
['a t] by a signature in [t]), as it it just requires loosening the
restriction on "same parameters" in member substitution to "a subset of the
parameters". But it's less modular and not as good for documentation. But
it would be sufficient for many use-cases.

 That would break a lot of existing code and wouldn't work very well
> without a full effect system in the core language.
>

I don't think it would break that much (and if it breaks something the fix
is two characters long…). I mean, the functions exported by the functor
need not be pure. It's just the functor application which has to (that is
no reference or such at toplevel). I don't think an effect system is
required for that. But my question is mostly theoretical, anyway.

[-- Attachment #2: Type: text/html, Size: 2681 bytes --]

      reply	other threads:[~2014-10-22  9:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-21  8:52 Arnaud Spiwack
2014-10-21 12:26 ` Leo White
2014-10-21 12:47   ` Leo White
2014-10-21 13:19     ` Arnaud Spiwack
2014-10-21 14:52       ` Leo White
2014-10-22  9:51         ` Arnaud Spiwack [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=CAMoPVjeqUt0HzBcJa5mh84PxFF7JEmEb5Gyd6hQexFzqEcRWpA@mail.gmail.com \
    --to=arnaud@spiwack.net \
    --cc=caml-list@inria.fr \
    --cc=lpw25@cam.ac.uk \
    /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).