From: Thomas Braibant <thomas.braibant@gmail.com>
To: OCaML Mailing List <caml-list@inria.fr>
Subject: [Caml-list] Quizz
Date: Tue, 13 Jan 2015 18:09:54 +0100 [thread overview]
Message-ID: <CAHR=Vkx1Lb43qh5QtcnKM2tw=64m6NuU8xsd0CoFR5P7tP2X8g@mail.gmail.com> (raw)
Hi list,
Here is a quizz that can easily be solved using OCaml (version
4.02.1), but it would be less fun than trying to infer which functions
are accepted.
```
module type S = sig val test : 'a list end
type t = (module S)
let a (x : t) =
let module M = (val x) in
List.length M.test
let b (module M : S) =
List.length M.test
let c ((module M) : t) =
List.length M.test
let d (module M : t) =
List.length M.test
let e (x : (module S)) =
let module M = (val x) in
List.length M.test
let f ((module M) : (module S)) =
List.length M.test
let g : (module S) -> int = fun (module M) ->
List.length M.test
let h ((module M) : (module sig val test : 'a list end)) =
List.length M.test
```
(I am sure I have missed interesting variations, though.)
I have read through
http://caml.inria.fr/pub/docs/manual-ocaml/types.html,
http://caml.inria.fr/pub/docs/manual-ocaml/modtypes.html
http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec230
but what I do not get is how to make a variation of `h` work. That is,
I would like to inline the module signature. Is that possible?
Best,
Thomas
next reply other threads:[~2015-01-13 17:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 17:09 Thomas Braibant [this message]
2015-01-13 20:51 ` Leo White
2015-01-13 21:10 ` Milan Stanojević
2015-01-14 0:09 ` Leo White
2015-01-14 7:02 ` Jacques Garrigue
2015-01-14 16:32 ` Milan Stanojević
2015-01-14 17:24 ` Leo White
2015-01-15 9:41 ` 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='CAHR=Vkx1Lb43qh5QtcnKM2tw=64m6NuU8xsd0CoFR5P7tP2X8g@mail.gmail.com' \
--to=thomas.braibant@gmail.com \
--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