caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nicolás Ojeda Bär" <nicolas.ojeda.bar@lexifi.com>
To: Serge Sivkov <ssp.mryau@gmail.com>
Cc: OCaml Mailing List <caml-list@inria.fr>
Subject: Re: [Caml-list] module and it's types as function parameters
Date: Thu, 23 Nov 2017 14:14:24 +0100	[thread overview]
Message-ID: <CADK7aFO54QW_-vKr6vvGNSTeTFWKSTpc1SsFW54wXJUB9mwgYQ@mail.gmail.com> (raw)
In-Reply-To: <CAOUGqWxOq6ndU9z61u1ML5iABW7Wn+AdcfNKRtLjnoNes+2zyA@mail.gmail.com>

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

Dear Serge,

If I understand correctly what you are asking, then you can make it work by
wrapping the definition of topicf in an existential:

  module R = struct
    type topicf = TF : ((module I with type message = 'a) -> 'a -> 'a) ->
topicf
    and topic = { func: topicf; name: string }
    ...
  end

then, given test, you can create an R.topic by doing

  { R.func = TF test; name = "test" }

Best wishes,
Nicolás


On Thu, Nov 23, 2017 at 1:52 PM, Serge Sivkov <ssp.mryau@gmail.com> wrote:

> Hello,
>
> is there way to define module with similar interface:
>
> module R = struct
>         type topicf = (module F : I) -> F.message -> F.message
>         and topic = { func: topicf; name: string }
>         ...
> end
>
> it is possible in case I want to define function with similar signature I
> can declare used types by:
> let test (type message') (module M : I with type message = message') (v:
> message') : message' = ...
>
> But how should I create such type in module?
>
> WBR, ssp
>

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

  reply	other threads:[~2017-11-23 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23 12:52 Serge Sivkov
2017-11-23 13:14 ` Nicolás Ojeda Bär [this message]
2017-11-24  5:27   ` Serge Sivkov

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=CADK7aFO54QW_-vKr6vvGNSTeTFWKSTpc1SsFW54wXJUB9mwgYQ@mail.gmail.com \
    --to=nicolas.ojeda.bar@lexifi.com \
    --cc=caml-list@inria.fr \
    --cc=ssp.mryau@gmail.com \
    /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).