caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Arnaud Spiwack <Arnaud.Spiwack@lix.polytechnique.fr>
Cc: OCaML Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] One-value functors
Date: Thu, 17 May 2012 16:52:33 +0200	[thread overview]
Message-ID: <87ehqi97wu.fsf@frosties.localnet> (raw)
In-Reply-To: <CAMoPVjchxsQ5QDdsfBU+TDVmhAxrBUndDNJzVP==WT1vcE8gcw@mail.gmail.com> (Arnaud Spiwack's message of "Fri, 11 May 2012 12:03:32 +0200")

Arnaud Spiwack <Arnaud.Spiwack@lix.polytechnique.fr> writes:

> Dear all,
>
> With the advent of first-class modules, I find myself more and more wanting to
> write functors with only one (value) component, just to benefit from type
> dependencies. Here is an example (randomly) extracted from Oleg Kiselyov and
> Jeremy Yallop:
>
>
>     type a and b
>     module type TC = sig type 'a t end
>     module type Subst = functor (A:TC) -> sig val x : a A.t -> b A.t end

What are you trying to do there? Why do you need a functor for that at
all? TC just having a type doesn't make sense to me.

> If this pattern had to become widespread, it would be worth agreeing for a name
> on the single component, though it's a bit unnecessary to need a name at all.
> It get very verbose, though, when trying to applying the functor. Supposing I
> have a module Subst:Subst :
>
>
>     let module S = Subst(sig type 'a t = 'a list) in
>     S.x ?

So S.x would be a function that turns for example an int list into a
float list, e.g. let x list = List.map float_of_int list?

How would you write Subst that it takes anything but 'a list (and
Obj.magic doesn't count)? How would the functor look like that would
accept 'a list or 'a array as argument? Seems to me TC needs to also
contain the map function for this to work. And then why not just use
(List.map float_of_int) as closure?

> I believe this would be something cool to have, so I came with two questions:
> 1/ Is there some demand for this kind of things (if not, I'm not sure it's
> worth pursuing, though of course demand could appear after supply)
> 2/ I don't see how to define the type syntax in camlp4, because of the inlining
> thing, could it be done?
>    (an alternative may be to have (X:A) => t be a module type, but then  (X:A)
> => (Y:B) => t is not a valid type, so we would need syntaxes for n-ary
> abstraction/applications)

Hard to say if I can't even understand what "this kind of thing" is.

MfG
        Goswin

  reply	other threads:[~2012-05-17 14:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-11 10:03 Arnaud Spiwack
2012-05-17 14:52 ` Goswin von Brederlow [this message]
2012-05-17 16:23 ` Nicolas Braud-Santoni
2012-05-21  9:25   ` Arnaud Spiwack
2012-05-30 14:14     ` Arnaud Spiwack

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=87ehqi97wu.fsf@frosties.localnet \
    --to=goswin-v-b@web.de \
    --cc=Arnaud.Spiwack@lix.polytechnique.fr \
    --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).