caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Quizz
@ 2015-01-13 17:09 Thomas Braibant
  2015-01-13 20:51 ` Leo White
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Braibant @ 2015-01-13 17:09 UTC (permalink / raw)
  To: OCaML Mailing List

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-01-15  9:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13 17:09 [Caml-list] Quizz Thomas Braibant
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

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).