<BenceF>
Does somebody know a js_of_ocaml (or reason/rescript) project that uses menhir?
alphacentauri has joined #ocaml
jlrnick has joined #ocaml
jlrnick has quit [Ping timeout: 255 seconds]
BenceF has quit [Ping timeout: 264 seconds]
waleee has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
bartholin has joined #ocaml
mro has quit [Quit: Leaving]
<Leonidas>
How do I instantiate a functorized module type in a module signature?
waleee has quit [Ping timeout: 272 seconds]
<Leonidas>
I used to have `include FOO` but now FOO is a functor module type, but `include FOO(M)` seems to be a syntax error
alphacentauri has quit [Quit: WeeChat 4.0.5]
<discocaml>
<Kali> try `include module type of ...`
alphacentauri has joined #ocaml
<Leonidas>
Unbound module FOO Hit: Hint: There is a module type named S.CONTEXT, but module types are not modules
<Leonidas>
Unbound module FOO Hint: There is a module type named FOO, but module types are not modules
<Leonidas>
it seems like it is missing the application
<discocaml>
<Kali> hm..
<discocaml>
<Kali> oh, wait, of course; it is impossible to apply functorized type signatures just as it is impossible to apply function types to other types
<discocaml>
<Kali> what you can do is instantiate an actual module with that signature and recover the signature with `module type of`
<discocaml>
<Kali> let me write an example
<Leonidas>
I thought about doing `include module type of struct include FOO(M) end` but that doesn't work, so yeah, an example would be very helpful
<discocaml>
<Kali> module Test(M:sig type t val x : t end) = struct
<discocaml>
<Kali> include M
<discocaml>
<Kali> end
<discocaml>
<Kali>
<discocaml>
<Kali> module Test2 = struct
<discocaml>
<Kali> type t = int
<discocaml>
<Kali> let x = 1
<discocaml>
<Kali> end
<discocaml>
<Kali>
<discocaml>
<Kali> module type Test3 = sig
<discocaml>
<Kali> include module type of Test(Test2)
<discocaml>
<Kali> end
<discocaml>
<Kali> ```
<discocaml>
<Kali> oops, sorry about the bad formatting
<discocaml>
<bnguyenv> You can create a functor that will return the correct module type as its sole component, and actually use that in your functor definition to constrain the return signature too.
<discocaml>
<Kali> wait, yes, this is a better idea
<discocaml>
<bnguyenv> Like `module F (A : ...) (B : ...) : sig module type S = sig type t = A.t ... end end`
<discocaml>
<bnguyenv> oops `struct` for the body of `F` of course
<discocaml>
<bnguyenv> (credits to octachron for this pattern)
<Leonidas>
Ok, need to see whether and how I can change my code, because that does look nice
nore has quit [Ping timeout: 245 seconds]
alphacentauri has quit [Quit: WeeChat 4.0.5]
azimut has joined #ocaml
alphacentauri has joined #ocaml
John_Ivan__ has quit [Quit: Disrupting the dragon's slumber one time too often shall eventually bestow upon all an empirical and indiscriminate conflagration that will last for all goddamn eternity.]
John_Ivan has joined #ocaml
<Leonidas>
Kali: I think your solution doesn't work for me because in your example the modules are modules, in my codebase they would be functor arguments
<Leonidas>
I am unsure whether that functor application would even generate compatible types
<Leonidas>
but it seems like if I make both C and M functor arguments, I can do `include module type of C(M)` which at least compiles :-)
ursa-major has joined #ocaml
dh` has quit [Ping timeout: 255 seconds]
dh` has joined #ocaml
dh` has quit [Ping timeout: 252 seconds]
dh` has joined #ocaml
Tuplanolla has joined #ocaml
ursa-major has quit [Quit: WeeChat 4.0.5]
waleee has joined #ocaml
<Leonidas>
Another odd problem (I would google it but not sure what to even google for). I have a `include module type of C(M)` in my signature and `C(M).t` is just an abstract type. In my implementation it's a record. Before I functorized C it worked and picked up that `t` is abstract but not anymore.
<Leonidas>
Type declarations do not match: type t = Dir_context(M)(C).t = { ... } is not included in type t = C(M).t The type t is not equal to the type C(M).t
<Leonidas>
Maybe the fact that C(M).t is abstract because it lost the information when I asked for `module type of C(M)`?
Serpent7776 has quit [Ping timeout: 258 seconds]
<discocaml>
<usdt0865> I will help you how to earn $40k or more within 72hours from the Crypto Market, but you’ll pay me a 10% of your profit when you receive it.
<discocaml>
<usdt0865> If interested, send me a direct message. For more information…contact via 👇