caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] mixing GADTs and first class modules
@ 2015-03-18 10:19 Maxence Guesdon
  2015-03-18 10:24 ` Jeremy Yallop
  0 siblings, 1 reply; 3+ messages in thread
From: Maxence Guesdon @ 2015-03-18 10:19 UTC (permalink / raw)
  To: caml-list

Hello,

I thought that something like this was possible:

module type M = sig type t end;;
type _ foo = T : (module M) -> M.t foo;;

but it does not seem so, as I can't refer to type t of the module
parameter:
Error: Unbound type constructor M.t

Is there a workaround ?

Regards,

Maxence

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

* Re: [Caml-list] mixing GADTs and first class modules
  2015-03-18 10:19 [Caml-list] mixing GADTs and first class modules Maxence Guesdon
@ 2015-03-18 10:24 ` Jeremy Yallop
  2015-03-18 10:28   ` Maxence Guesdon
  0 siblings, 1 reply; 3+ messages in thread
From: Jeremy Yallop @ 2015-03-18 10:24 UTC (permalink / raw)
  To: Maxence Guesdon; +Cc: Caml List

On 18 March 2015 at 10:19, Maxence Guesdon <Maxence.Guesdon@inria.fr> wrote:
> module type M = sig type t end;;
> type _ foo = T : (module M) -> M.t foo;;
>
> but it does not seem so, as I can't refer to type t of the module
> parameter:
> Error: Unbound type constructor M.t
>
> Is there a workaround ?

Yes:

  type _ foo = T : (module M with type t = 'a) -> 'a foo

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

* Re: [Caml-list] mixing GADTs and first class modules
  2015-03-18 10:24 ` Jeremy Yallop
@ 2015-03-18 10:28   ` Maxence Guesdon
  0 siblings, 0 replies; 3+ messages in thread
From: Maxence Guesdon @ 2015-03-18 10:28 UTC (permalink / raw)
  To: Jeremy Yallop; +Cc: Caml List

On Wed, 18 Mar 2015 10:24:34 +0000
Jeremy Yallop <yallop@gmail.com> wrote:

> On 18 March 2015 at 10:19, Maxence Guesdon <Maxence.Guesdon@inria.fr> wrote:
> > module type M = sig type t end;;
> > type _ foo = T : (module M) -> M.t foo;;
> >
> > but it does not seem so, as I can't refer to type t of the module
> > parameter:
> > Error: Unbound type constructor M.t
> >
> > Is there a workaround ?
> 
> Yes:
> 
>   type _ foo = T : (module M with type t = 'a) -> 'a foo

Nice, thanks !

- m

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

end of thread, other threads:[~2015-03-18 10:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18 10:19 [Caml-list] mixing GADTs and first class modules Maxence Guesdon
2015-03-18 10:24 ` Jeremy Yallop
2015-03-18 10:28   ` Maxence Guesdon

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