mongol has quit [Remote host closed the connection]
bartholin has joined #ocaml
Serpent7776 has joined #ocaml
bartholin has quit [Quit: Leaving]
asm has quit [Read error: Connection reset by peer]
cedric has joined #ocaml
cedric has quit [Quit: Konversation terminated!]
gareppa has joined #ocaml
lobo has quit [Server closed connection]
lobo has joined #ocaml
m5zs7k has quit [Ping timeout: 250 seconds]
m5zs7k has joined #ocaml
azimut has quit [Ping timeout: 240 seconds]
xd1le has joined #ocaml
kakadu has joined #ocaml
Tuplanolla has joined #ocaml
kakadu has quit [Quit: Konversation terminated!]
pie_ has quit []
pie_ has joined #ocaml
Johann_ has quit [Server closed connection]
Johann_ has joined #ocaml
<discocaml>
<xavierm02_> Is there an idiomatic way of making explicit that the onus is on the programmer to check that some invariant holds when using a function? When the invariants are simple enough to be decidable, one can simply check that they hold and throw an exception if they do not, but they often are not. For example, it would be reasonable to have `module Injection : sig type ('a, 'b) t = private 'a -> 'b val of_fun : ('a -> 'b) -> ('a, 'b) t end`, and
<discocaml>
<xavierm02_> I'd like to make this explicit because otherwise, one might use `Injection.of_fun` without checking the invariants just like e.g. `MemoizedFunction.of_fun`.
<discocaml>
<xavierm02_> Maybe defining a type `type promise = IPromiveThatICheckedTheInvariants` and then `val of_fun : ('a -> 'b) -> promise -> ('a, 'b) t`?
<discocaml>
<leviroth> Seems reasonable, though in a lot of contexts putting something about injectivity in a labeled argument may accomplish the same goal.
<discocaml>
<xavierm02_> Ah so `val of_fun : i_promise_that_i_checked_the_invariants: unit -> ('a -> 'b) -> ('a, 'b) t`?
szkl has joined #ocaml
<discocaml>
<leviroth> That could work, but I was thinking of something slightly different. I was assuming that if you need the user to provide an injective function `f`, they're probably providing it as a function argument to some higher-order function `h` (maybe there are other cases though). So you could have `h`'s argument be labeled e.g. `val h : injective_function:('a -> 'b) -> ...`
ocabot has quit [Server closed connection]
ocabot has joined #ocaml
discocaml has quit [Server closed connection]
discocaml has joined #ocaml
companion_cube has quit [Server closed connection]
companion_cube has joined #ocaml
<discocaml>
<xavierm02_> The actual type contains more than just the function, so it's easier to have everything take arguments of type `('a, 'b) t`. But I guess this also applies to `of_fun`, I could have `of_fun : injective_function: ('a -> 'b) -> more_stuff -> ('a, 'b) t`.
<discocaml>
<xavierm02_> I think I'll go with that. Thank you!
theblatte has quit [Server closed connection]
theblatte has joined #ocaml
waleee has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
neiluj has joined #ocaml
<neiluj>
hi! trying to pass a module in a function: let f ((module B_mod) : (sig include module type of A.B end)) = (module struct ...)
<neiluj>
why is the signature of B_mod not accepted? there is a syntax error near the sig
kurfen_ has quit [Ping timeout: 240 seconds]
kurfen has joined #ocaml
<octachron>
The type of first class modules needs to be an explicitly named module type.
<discocaml>
<xavierm02_> neiluj: I think it should be `let f ((module M) : (module S)) = ...` or `let f (module M : S) = ...` instead of `let f ((module M) : S) = ...`
<discocaml>
<xavierm02_> In addition to what octachron said, so adding `module type S = sig include module type of A.B end` before the definition of `f`
<adrien>
hi, is there a syntax to deconstruct labelled arguments?
<neiluj>
it works, many thanks!
<octachron>
let f ~x:(Some _ | None) = ()
<adrien>
octachron: thanks! :)
<neiluj>
can you pass a functor to a function?
<octachron>
first class module can contain functors
<neiluj>
indeed:)thx!
<discocaml>
<xavierm02_> Is it possible to "open" constructor or field names without "opening" the corresponding type? More precisely, is it possible to replace `open M` by something else to get this code to typecheck: https://pastebin.com/h5681xsd
<discocaml>
<xavierm02_> I know there are other ways to make this compile such as `let f ({field} : M.t) = field + 1` or `let f {M.field} = field + 1`, but I'm looking for an alternative to the open
<discocaml>
<xavierm02_> If the type lives in another module, this can be done with ppx_import, e.g. `open (struct type%import other_name = M.t end)`, but otherwise, I don't know how to keep the definition of t while renaming it
<discocaml>
<octachron> You can re-export the type definition by hand.
<discocaml>
<octachron> But that sounds like a complicated solution to avoid having an alias for the toplevel `t` or using qualified field names.
<discocaml>
<xavierm02_> I was hoping there was some trick with a `:=` substitution on module types 😦
dhil has joined #ocaml
daftaupe has quit [Remote host closed the connection]
daftaupe has joined #ocaml
mechap has joined #ocaml
bartholin has joined #ocaml
xd1le has quit [Quit: xd1le]
hannes has joined #ocaml
alexherbo2 has joined #ocaml
yewscion has quit [Read error: Connection reset by peer]
azimut has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
neiluj has quit [Quit: WeeChat 3.8]
alexherbo2 has joined #ocaml
smko has joined #ocaml
smko has quit [Quit: Lost terminal]
John_Ivan__ has joined #ocaml
John_Ivan_ has quit [Ping timeout: 260 seconds]
John_Ivan__ has quit [Ping timeout: 246 seconds]
smko has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]