companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.0 released(!!1!): https://ocaml.org/releases/5.0.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
noonien has quit [Ping timeout: 250 seconds]
waleee has quit [Ping timeout: 246 seconds]
noonien3 has joined #ocaml
Haudegen has quit [Ping timeout: 268 seconds]
chrisz has quit [Ping timeout: 265 seconds]
chrisz has joined #ocaml
spip has quit [Ping timeout: 265 seconds]
riverdc has quit [Ping timeout: 268 seconds]
riverdc has joined #ocaml
hrberg has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
hrberg has joined #ocaml
remexre has quit [Ping timeout: 268 seconds]
remexre has joined #ocaml
Haudegen has joined #ocaml
alexherbo2 has joined #ocaml
bartholin has joined #ocaml
spip has joined #ocaml
<discocaml> <.sarna.> I'm writing an interpreter. I have a module `Object` that is used by `Environment` (which holds name -> `Object.t` pairs). `Environment.t` is used by the interpreter. but then, one of the `Object.t` variants is `Callable`, and it needs a pointer to `Interpreter.t` - aand I have a dependency cycle
<discocaml> <.sarna.> (object -> environment -> interpreter -> object)
<discocaml> <.sarna.> any idea how to break it up? I tried many times and only failed so far..
<discocaml> <Kakadu> Could you add a type parameter to environment and put Object.t there?
dhil has joined #ocaml
Tuplanolla has joined #ocaml
dhil has quit [Ping timeout: 240 seconds]
<discocaml> <.sarna.> I got a new cycle.. I added another type parameter though, and it *almost* works - the only thing I have left is: `exception My_exception of Foo.t * string`
<discocaml> <.sarna.> how can I make something like this compile? `exception My_exception of 'a Foo.t * string`
<discocaml> <.sarna.> is it possible? docs say that `exception` needs a "type expression", and further that "Type constructors with no parameter, as in typeconstr, are type expressions."..
azimut has joined #ocaml
sllk_ has joined #ocaml
sllk has quit [Ping timeout: 268 seconds]
<discocaml> <NULL> The information of type `'a` would be lost in the exception, so you cannot do that
alexherbo2 has quit [Remote host closed the connection]
<discocaml> <.sarna.> then I'm hopelessly stuck 🫠
justache- has joined #ocaml
justache has quit [Ping timeout: 268 seconds]
<discocaml> <.sarna.> ok I solved it by making a `Types` module and putting all the type definitions there. I have functions in other modules
<discocaml> <.sarna.> not satisfying, but works..
<discocaml> <.sarna.> (also, had to add a ton of type hints)
Serpent7776 has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
alexherbo2 has joined #ocaml
Haudegen has joined #ocaml
Haudegen has quit [Client Quit]
<discocaml> <octachron> To avoid the hint issue, you can re-export the types in their respective module
<discocaml> <octachron> `module Object = struct type t = Types.Object = .... . end`
<discocaml> <octachron> `module Object = struct type t = Types.object = .... . end`
alexherbo2 has quit [Remote host closed the connection]
<discocaml> <.sarna.> ah neat, I'll try that
szkl has quit [Quit: Connection closed for inactivity]
justache- is now known as justache
gareppa has joined #ocaml
xavierm02 has joined #ocaml
bartholin has quit [Quit: Leaving]
gareppa has quit [Quit: Leaving]
xavierm02 has quit [Ping timeout: 246 seconds]
waleee has joined #ocaml
Haudegen has joined #ocaml
bartholin has joined #ocaml
dme2 has joined #ocaml
<discocaml> <.sarna.> hey, I noticed that when I have `Printexc.record_backtrace` it kills performance when using exceptions for exiting loops (my program gets overall 15x slower). I'm using `raise_notrace` for this - any clue why the backtrace still seems to be generated? can I disable it somehow/use a different mechanism?
<discocaml> <.sarna.> for now I found out that `Base.Exn.raise_without_backtrace` works (ie truly doesn't generate a backtrace and doesn't result in a slowdown)
xavierm02 has joined #ocaml
xavierm0251 has joined #ocaml
xavierm02 has quit [Ping timeout: 268 seconds]
<companion_cube> Hmm, do you raise the exception in a different function than the place it's caught in?
<companion_cube> How do you know a trace is still generated?
<xavierm0251> Hi. I would like to know if it is possible to track which constructors of an inductive type are used in a term. I tried using a GADT indexed by polymorphic variants, which manages to track which constructors are used when building a term, but fails to see that replacing a constructor A by another constructor C in a term with no constructor B always
<xavierm0251> yields a term without any constructor B: https://pastebin.com/Z8f0G154
<discocaml> <.sarna.> companion_cube: I know because my program gets 15x slower and in profiling I can see `caml_get_exception_raw_backtrace` takes 80% of execution time
<discocaml> <.sarna.> and yes, it's crossing function boundaries - is it important? if it says "notrace" I'd expect no trace..
<companion_cube> I'm not sure, but at least I know that the compiler can't know that this will never escape
<companion_cube> I try to keep that inside a function so it knows that the exception is local
<companion_cube> I feel stupid, but what's the email address to write on dicuss? I'm on my phone and I don't have it in my contacts as usual 😅
xavierm0251 has quit [Ping timeout: 268 seconds]
<octachron> xavierm0251, you can add a type tag to every variants. However, polymorphic variants are not really a good fit. Typically, your type or `replace_A_by_C` is not valid. With a closed set of variants/tags, the dual object types work somehow better.. And like always with GADT you need to annotate every functions.
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
xavierm02_ has joined #ocaml
xavierm02_ has quit [Quit: Ping timeout (120 seconds)]
bartholin has quit [Quit: Leaving]
xavierm02_ has joined #ocaml
<xavierm02_> octachron: I tried making it work with objects by having one field name per constructor, and the type of that field indicating whether the constructor was used or not, but the type I get for replace_A_by_C is too strict. https://pastebin.com/38ZSnUxy
<xavierm02_> I also tried representing the use a constructor by the presence of a field, but that did not work either.
Serpent7776 has quit [Ping timeout: 250 seconds]
<xavierm02_> (I'll disconnect now, but will read the logs tomorrow)
xavierm02_ has quit [Quit: Connection closed]