companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.12 released: https://ocaml.org/releases/4.12.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
Stumpfenstiel has quit [Ping timeout: 258 seconds]
<Corbin> In https://caml.inria.fr/pub/old_caml_site/caml-list/0838.html there is a warning about lost polymorphism when writing in the point-free style. Is that still a problem today, or was this a 90s issue?
<Corbin> A quick test at toplevel seems to work just fine; it produces types with names like '_weak1 which I'm guessing is related to however this was fixed.
zebrag has quit [Ping timeout: 240 seconds]
glassofethanol has quit [Ping timeout: 258 seconds]
glassofe1hanol has quit [Ping timeout: 258 seconds]
glassofethanol has joined #ocaml
glassofe1hanol has joined #ocaml
Haudegen has quit [Ping timeout: 240 seconds]
glassofe1hanol has quit [Ping timeout: 240 seconds]
glassofethanol has quit [Ping timeout: 240 seconds]
<d_bot> <NULL> '_weak1 is a weak polymorphic type variable; it isn't the same as 'a
<d_bot> <NULL> See https://ocaml.org/manual/polymorphism.html#ss:weak-types for the general explanation
<Corbin> Wonderful, thanks. This limitation seems acceptable and reasonable to me, and it's cool to see the different ways to work around it.
Tuplanolla has quit [Quit: Leaving.]
waleee has quit [Ping timeout: 245 seconds]
waleee has joined #ocaml
toppler` is now known as toppler
toppler has quit [Remote host closed the connection]
toppler has joined #ocaml
favonia has quit [Ping timeout: 252 seconds]
favonia has joined #ocaml
waleee has quit [Ping timeout: 255 seconds]
Melantha has quit [Quit: WeeChat 3.2]
Melantha has joined #ocaml
mbuf has joined #ocaml
gravicappa has joined #ocaml
bartholin has joined #ocaml
mro has joined #ocaml
mro has quit [Quit: Leaving...]
olle has joined #ocaml
cedric has joined #ocaml
dhil has joined #ocaml
reynir has quit [Ping timeout: 252 seconds]
reynir has joined #ocaml
gravicappa has quit [Ping timeout: 245 seconds]
gravicappa has joined #ocaml
gravicappa has quit [Ping timeout: 252 seconds]
gravicappa has joined #ocaml
glassofethanol has joined #ocaml
glassofethanol has quit [Ping timeout: 265 seconds]
029AAF03E has joined #ocaml
047AADJNQ has joined #ocaml
glassofethanol has joined #ocaml
<d_bot> <dj charlie> anyone have issues with hashtbl without making a string version of it with a functor? some values aren't being added
<d_bot> <dj charlie> could swear this is the hashing function
<d_bot> <dj charlie> ah nevermind found out that this something else
<d_bot> <sarna> hey, how do you compose results in OCaml? I'd like to end up with something similar to a stack trace (this error caused by that, caused by the other thing)
<olle> Lists?
<d_bot> <sarna> I'm reading https://keleshev.com/composable-error-handling-in-ocaml but the errors come from a library (`bos` in this case)
<olle> Exception + stack trace enabled
<d_bot> <sarna> hmm, that's certainly the simplest option I haven't considered
<d_bot> <sarna> I'd really like to do this with result types though, is it possible?
<olle> Ok
<olle> Then I don't know :)
<d_bot> <yberreby> I don't think you could recover context information if it wasn't provided at the time the error was raised / re-raised, either through explicitly wrapping it in a result type, or through the stack trace as @olle said
<d_bot> <Emiyo> Is this matrix bridge ?
<d_bot> <sarna> theoretically I could do this like in go, and make errors wrap other errors
<d_bot> <yberreby> that's the way the Rust community handles the problem, and its error handling approach was heavily inspired by OCaml
<d_bot> <sarna> can we be inspired by Rust in turn?
<d_bot> <sarna> irc
<d_bot> <yberreby> why not? The type systems share a lot of similarities
<olle> Why manually do exceptions when we have exceptions? Exceptions are fine in GC systems.
<d_bot> <sarna> I'm writing an application, Rust has crates like `anyhow` for this use case. is there any OCaml library that can help me here?
<d_bot> <sarna> but exhaustiveness :(
<olle> That's right, you won't get that until typed effects are in place.
<olle> You *can* catch exceptions in match-expressions tho
<d_bot> <sarna> with typed effects I'll be able to get exhaustive checks using exceptions?
<olle> Exception is a special case of an effect
<d_bot> <yberreby> I can't answer that, I'm just going back to OCaml after setting it aside for a couple years and I'm still rather unfamiliar with the 3rd-party ecosystem
<d_bot> <sarna> I mean my main issue with that is that I don't know what can throw and when, and with that I feel like I lose a lot from the static typing benefits
<d_bot> <sarna> I see, same here!
<olle> True
<d_bot> <sarna> Rust panics rarely (I feel) but a lot of stuff can throw exceptions in OCaml
<d_bot> <yberreby> That being said, I came here with a question of my own... I'm trying to wrap my head around the limitations of generics with higher-order functions. I would like to retain the genericity of a closure passed to another function; late binding of a type variable, basically?
<d_bot> <yberreby>
<d_bot> <yberreby> I'd like an example like this to work out:
<d_bot> <yberreby>
<d_bot> <yberreby> ```ocaml
<d_bot> <yberreby> let id (x : 'a) : 'a = x ;;
<d_bot> <yberreby>
<d_bot> <yberreby> let foo (f : ('a -> string) -> 'a list -> string) : string =
<d_bot> <yberreby> f string_of_int [1; 2]
<d_bot> <yberreby> ^ f id ["a"; "b"]
<d_bot> <yberreby> ;;
<d_bot> <yberreby> ```
<d_bot> <yberreby>
<d_bot> <yberreby> From my (limited) understanding, I guess the first use of `f` specializes its type signature in the body of the function?
<d_bot> <yberreby> Yup, `panic`s in Rust are idiomatically reserved for unrecoverable errors
<d_bot> <sarna> ah, also - I can't use exceptions, as `bos` doesn't have `_exn` equivalents for functions that return results haha
<olle> yberr, you might need to add the `type 'a.` blaha thingy to enforce proper polymorphism
<olle> sarna, the old parts of stdlib uses exn for "normal" code flow. it's being replaced by _opt versions of same functions.
<kakadu> yberreby: or something like: type t = { f : 'a. ('a -> string) -> 'a list -> string }
<kakadu> let foo (f : t) : string = f.f string_of_int [ 1; 2 ] ^ f.f Fun.id [ "a"; "b" ]
<d_bot> <sarna> olle: the errors come from `bos`, not stdlib
<d_bot> <sarna> this one https://erratique.ch/software/bos
<d_bot> <yberreby> I tried, but this still will not compile:
<d_bot> <yberreby> ```ocaml
<d_bot> <yberreby> let foo : 'a. (('a -> string) -> 'a list -> string) -> string = fun f ->
<d_bot> <yberreby> f string_of_int [1; 2]
<d_bot> <yberreby> ^ f id ["a"; "b"]
<d_bot> <yberreby> ;;
<d_bot> <yberreby> ```
<d_bot> <yberreby> If you're trying to get context on errors raised outside of your own code, without exceptions, I'm not sure that's possible?
<d_bot> <sarna> ah, you gave me an idea. I forgot that I could wrap `bos` errors in my own errors, they'd always be at the end of the error chain so I don't need *them* to wrap anything
<d_bot> <yberreby> Thank you, I saw this solution in the OCaml manual on higher-rank polymorphism, but I wasn't sure how idiomatic this was
<d_bot> <sarna> I'll try doing this and see if it works out. thanks @yberreby!
<d_bot> <yberreby> Yes, if the "stack trace" of sorts you want pertains to your own codebase, that seems most logical to me
<d_bot> <yberreby> Glad I could be of some help!
<d_bot> <yberreby> I wonder, is having to resort to universally-quantified record fields considered OK or are there plans to extend the type system so as not to need this workaround?
<olle> I don't see why record field would be needed there. kakadu
<olle> ?
<d_bot> <yberreby> they're one of the two approaches recommended by the OCaml manual: https://ocaml.org/manual/polymorphism.html
<d_bot> <yberreby> (subsection 3, "Higher-rank polymorphic functions")ร 
<olle> hmmm
<kakadu> olle: 1) It looks like guy needs non-prenex polymorphism for `f` 2) The solution with explicit 'a doesn't work for me:)
<olle> Oh yeah
<olle> Hm
<d_bot> <yberreby> I can confirm that your solution works just fine, kakadu, ty
<d_bot> <yberreby> I feel a bit dirty having to wrap my functions in records like this, but at least there's a solution that doesn't require taking the same callback several time with different type variables...
Tuplanolla has joined #ocaml
<kakadu> I think without wrapping to the record the type inference wouldn't be able to genereate the most general type, so...
<olle> Stupid type inference
<olle> Just use ADT ;)
<d_bot> <yberreby> Does ADT have another meaning than Abstract Data Types here?
<olle> Algebraic*
<d_bot> <yberreby> Ah!
<d_bot> <yberreby> You mean replacing the type variable with a sum type?
<olle> Yeah
<olle> Say what you mean
<d_bot> <yberreby> I thought about doing something like that at first
<d_bot> <yberreby> but I'm not sure this is really cleaner
<d_bot> <yberreby> I also wonder if changing the signature of the callback so that `'a` becomes a (polymorphic?) variant doesn't just shift the problem to consumers of `foo`
<d_bot> <yberreby> and in both cases, some wrapping will be required to interact with functions that have a type signature with a plain type variable `'a`...
<olle> Why does it need to be polymorphic?
<d_bot> <yberreby> I'm not comfortable with them yet, but from what I've seen, they'd be easier to compose if I have many functions with similar-but-not-quite identical signatures using the same variants constructors?
<olle> No idea
<d_bot> <yberreby> I mean, you can cast a variant type to a more generic one effortlessly
<d_bot> <yberreby> That seems rather convenient?
<olle> How?
<olle> How could you cast it?
<d_bot> <yberreby> ```ocaml
<d_bot> <yberreby> let x = `Int 5;;
<d_bot> <yberreby> let y: [> `Int of int | `String of string] = x ;;
<d_bot> <yberreby> ```
<olle> Oh, poly variants
<d_bot> <yberreby> Maybe casting isn't the appropriate term here, but the type of `x` and that of `y` are different, one is a subtype of the other, and they interact well
<olle> Right
troydm has quit [Quit: What is Hope? That all of your wishes and all of your dreams come true? To turn back time because things were not supposed to happen like that (C) Rau Le Creuset]
pagnol has joined #ocaml
troydm has joined #ocaml
pagnol has quit [Ping timeout: 268 seconds]
Haudegen has joined #ocaml
terrorjack has quit [Remote host closed the connection]
terrorjack has joined #ocaml
osa1 has joined #ocaml
<osa1> I'm trying to use standard Str module in a project but `dune build` fails with "No implementations provided for the following modules: Str". Any tips?
<osa1> Had to add `str` to libraries in dune
glassofethanol has quit [Quit: leaving]
gzj has joined #ocaml
<d_bot> <dinosaure> do you know if it's possible to "serialize" a `Re.t` to an OCaml value such as the output can be compiled by `ocaml`? Like, `let () = Format.printf "%a%!\n" Re.serialize my_re" ;;` and `./serialize.ml > main.ml && ocamlfind opt -package re main.ml`?
hackinghorn has quit [Quit: Leaving]
Stumpfenstiel has joined #ocaml
gzj has quit [Remote host closed the connection]
gzj has joined #ocaml
029AAF03E has quit [Remote host closed the connection]
047AADJNQ has quit [Remote host closed the connection]
gzj has quit [Remote host closed the connection]
gzj has joined #ocaml
gzj has quit [Read error: Connection reset by peer]
gzj has joined #ocaml
gzj has quit [Remote host closed the connection]
gzj has joined #ocaml
gzj has quit [Remote host closed the connection]
adanwan_ has quit [Remote host closed the connection]
adanwan has joined #ocaml
<d_bot> <darrenldl> sounds like an interesting code gen idea
mbuf has quit [Quit: Leaving]
mro has joined #ocaml
motherfsck has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Quit: Leaving...]
mro has joined #ocaml
mro has quit [Read error: Connection reset by peer]
mro_ has joined #ocaml
mro_ has quit [Remote host closed the connection]
waleee has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 245 seconds]
kakadu_ has joined #ocaml
kakadu has quit [Ping timeout: 255 seconds]
kakadu_ has quit [Read error: Connection reset by peer]
mbuf has joined #ocaml
_whitelogger has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 252 seconds]
glassofethanol has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
glassofethanol has quit [Quit: leaving]
glassofethanol has joined #ocaml
glassofethanol has quit [Quit: leaving]
paravida has joined #ocaml
zebrag has joined #ocaml
mbuf has quit [Quit: Leaving]
mro has joined #ocaml
Stumpfenstiel has quit [Ping timeout: 256 seconds]
<d_bot> <rgrinberg> @dinosaure we have a `View` module that exports the AST. With a couple of functions to convert it to an actual regex it might do the job.
<d_bot> <dinosaure> yeah this is what I use ๐Ÿ™‚
Stumpfenstiel has joined #ocaml
olle has quit [Ping timeout: 258 seconds]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Ping timeout: 268 seconds]
berberman has quit [Ping timeout: 252 seconds]
gravicappa has quit [Ping timeout: 258 seconds]
olle has joined #ocaml
olle has quit [Ping timeout: 245 seconds]
mosterdt has quit [Ping timeout: 268 seconds]
mosterdt has joined #ocaml
mro has joined #ocaml
mro has quit [Quit: Leaving...]
Anarchos has joined #ocaml
<Anarchos> is it possible to install ocaml on an x86_64 architecture ?
<d_bot> <colin> yes, which platform? tends to be simpler on Linux and BSDs
<Anarchos> colin, i am not on linux neither BSD...
<d_bot> <colin> Windows then?
<d_bot> <Alistair> Is there a channel for compiler internals?
<d_bot> <colin> No, but I think the forum would be a good place for that
<d_bot> <colin> (I say "No" but that's just to my knowledge)
<d_bot> <colin> I think Leo White, gasche, etc. are most active there when it comes to discussing the internals
<d_bot> <colin> perhaps also inria's mailing list
<Anarchos> colin no windows , i am on Haiku
<Anarchos> alistair you can read the compiler internals in the ocaml weekly news too
<d_bot> <colin> I've never heard of Haiku but it falls outside the mainstream (that much is clear) so I don't think you'll be able to find a binary release for opam or whatever
<d_bot> <mseri> I think on haiku you should get ocaml sources and compile them by hand, not sure how feasible it is
<d_bot> <mseri> I think at least the unix library will need extra care
<d_bot> <mseri> Since many signals are different
cedric has quit [Quit: Konversation terminated!]
<d_bot> <mseri> Probably also lots of lowlevel api will need some special implementation
<d_bot> <mseri> I am curious to see how hard or easy it will be to make at least the bytecode interpreter work
<Corbin> Nix/nixpkgs question: Is there a blessed way to enable e.g. flambda for an entire ocamlPackages at once? I can take this to #nixos if it's off-topic.
<Anarchos> mseri ocaml compiles without changes on haiku , on a x86 32bits architecture, but i get error in makefile with x86_64
<d_bot> <mseri> Cool
bartholin has quit [Quit: Leaving]
<d_bot> <mseri> Does it actually work fine? It compiles and runs fine? I guess it is time I have another look at haiku
<d_bot> <mseri> Looks like there have been PRs to fix haiku support that landed in 4.11 (https://github.com/ocaml/ocaml/pull/9486) which version was failing for you?
<Corbin> (Solved my issue; I just made my own little `ocamlPackages_flambda` with `flambdaSupport = true;` and now it is compiling a custom ocaml just for me.)
<Anarchos> mseri it works fine on their 32bits version. I modified the configure.ac file of ocaml to let it compile on 64bits
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
<d_bot> <mseri> Got it thanks, I get slow when itโ€™s late. I hope to find the time to play around with it, I used to like BeOS a lot
<d_bot> <mseri> Good luck with fixing the error
<Corbin> (Oh hey, and https://nixos.wiki/wiki/OCaml#Custom_version makes it even easier.)
dhil has quit [Ping timeout: 240 seconds]
andreypopp has quit [Ping timeout: 276 seconds]
andreypopp has joined #ocaml