caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nicolas Braud-Santoni <nicolas@braud-santoni.eu>
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 18:23:37 +0200	[thread overview]
Message-ID: <CA+qp_4qiEQDiEhotX8dY1esLVeXqjorttW9EJLWvWUqmeaXTRQ@mail.gmail.com> (raw)
In-Reply-To: <CAMoPVjchxsQ5QDdsfBU+TDVmhAxrBUndDNJzVP==WT1vcE8gcw@mail.gmail.com>

Hi,

If I'm not mistaken, you want something like Haskell's typeclasses.
I agree that it's a feature I often find myself wanting in OCaml, and
-as you point out- is trivial to encode with module and functors, so
it shouldn't be highly problematic.

Is there some syntax extension providing such a feature ?
If not, are there plans to have syntax for typeclass-like functor operations ?

Regard,
Nicolas

2012/5/11 Arnaud Spiwack <Arnaud.Spiwack@lix.polytechnique.fr>:
> 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.
>[...]
>
> We could have the type
>> (X:A) => t
>
> stand for (something like)
>> module F = functor (X:A) -> sig val x : t end
>> (module F)
>
> and the definition
>> let f {{X:A}} = e
>
> stand for
>> let f = let module F (X:A) -> struct let x = e end
>
> and finally we'd need an application
>> e {{M}}
>
> would stand for (something like)
>> let module F = (val e) in let module F' = F(M) in F'.x
>
> Clearly the application needs something like OCaml 4.0 and the type
> definition some kind of cleverness (I don't know, by the way, why the syntax
> for F cannot be inlined in the type).
> [...]

  parent reply	other threads:[~2012-05-17 16:23 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
2012-05-17 16:23 ` Nicolas Braud-Santoni [this message]
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=CA+qp_4qiEQDiEhotX8dY1esLVeXqjorttW9EJLWvWUqmeaXTRQ@mail.gmail.com \
    --to=nicolas@braud-santoni.eu \
    --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).