companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.14.0 released: https://ocaml.org/releases/4.14.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
xenu has joined #ocaml
<pgiarrusso> also if you want an ML with mixin modules, there's always Scala — </s>? 🙃
<pgiarrusso> that's probably both accurate trolling and a serious answer, since Scala's explicitly goal is to combine ML modules and OO programming.
<companion_cube> I thought scala was doing objects, not modules? :)
<companion_cube> nothing more than OCaml's objects, in the end
<companion_cube> (is "mixing" the same as multiple inheritance in this domain?)
<pgiarrusso> companion_cube: Scala objects have abstract type members.
<companion_cube> ah yeah, and path dependency! maybe you're right
<companion_cube> but can you parametrize by another, err, "module"?
<pgiarrusso> companion_cube: `class A { type T }; class B(val o: A)(o2 : o.T) {}` works out
<companion_cube> my brain
<pgiarrusso> my old joke was that Scala's Mix1MLSub :-)
<companion_cube> anyway, that's quite cool, and scala3 also has *checks notes* sum types
<pgiarrusso> MixML + 1ML + (kinda) MLSub
<companion_cube> + null :(
<pgiarrusso> https://www.cs.cmu.edu/~aldrich/courses/819/odersky-scala-theory.pdf explicitly cites SML and Caml as a starting point
<pgiarrusso> Scala3 has some extra features for nullability checking, but I haven't tried it enough to comment
<pgiarrusso> but yes, I'm only saying that you can encode ML modules (with _generative_ functors) + mixin modules into Scala — whether you should is another matter
<companion_cube> oh good. although interop with java will always limit these efforts
<companion_cube> but good on them
<pgiarrusso> I've also joked that finding the ideal combination of all those features might take 50 years — so in a sense Scala is a preview of that design.
<pgiarrusso> (and Scala3 is nicer variant)
<pgiarrusso> anyway, I'll stop shilling
<companion_cube> my memory is that scala is what happens if you fully bite the subtyping bullet
<companion_cube> but my experience with it was only one year in grad school
<pgiarrusso> that's not a wrong summary
<companion_cube> guess you need to add the full type-level application bullet now
<companion_cube> it's a bit crazy, but I think it's nice that it exists
<companion_cube> aren't they also working on effects btw?
<pgiarrusso> ? type-level application?
<pgiarrusso> I mean they do have higher-kinded types, yes, but that seems a bit separate
<companion_cube> well, various forms of type-level magic that flirt with dependent types/type operators
<pgiarrusso> okay sure, but is it more than OCaml? Hmm...
<companion_cube> even your example above uses `o.T`, which is at least, err, path-dependent?
<companion_cube> more than OCaml, yes
<companion_cube> well, OCaml has this distinction between the expression world, and the module world (where you do have some type level applications)
<pgiarrusso> sure, but in OCaml you have both path-dependency and subtyping in the module language
<companion_cube> yes
<companion_cube> no HKT though
<pgiarrusso> I'm confused because "type-level application" includes `'a list` and `map`
<pgiarrusso> ah right
<companion_cube> no, 'a list is only a type scheme :)
<pgiarrusso> okay, type constructors etc are second-class in the core language
<pgiarrusso> and you can't have values that contain polymorphic functions???
<companion_cube> oh, you can! use a record or object :)
<pgiarrusso> okay
<companion_cube> type 'b cont = {run: 'a. ('b -> 'a) -> 'a}
<companion_cube> useful trick for all sorts of CPS
<pgiarrusso> but generally you're right — Scala is also what happens if you program only with the module language
<companion_cube> oooof, "undecidability of type checking" :s
<companion_cube> that's a title that hurts
<pgiarrusso> that automatically gives you first-class modules, subtyping and path dependency.
<companion_cube> just like 1ML, heh
<pgiarrusso> interfaces = signatures, classes = structures, ...
<pgiarrusso> re decidability, I thought OCaml _didn't_ have decidable typechecking?
<companion_cube> hmm guess it depends on your exact definition
<pgiarrusso> IIRC Scala 2 took some steps towards decidable typechecking, but it wasn't really worthwhile
<companion_cube> it doesn't have decidable type inference, but I *think* that any typable program can be accepted with enough type annotations
<companion_cube> (notably in presence of GADTs)
<companion_cube> ie a fully type annotated program should be type-checkable
<Corbin> https://lobste.rs/s/xngt2a/abstract_machines_compilers_love_hate I have feelings about this, having just implemented a CAM, but I'm not sure exactly what those feelings are. Maybe other folks will have feelings.
<pgiarrusso> I mean, "decidable typechecking" has a definition: the typechecker never loops. Taking Ackermann(4, 4) steps, however, is allowed :-)
<pgiarrusso> companion_cube: will it reject programs without enough annotations, or loop?
<companion_cube> reject
<companion_cube> it'll try to pick a type that just happens to not be polymorphic enough
<pgiarrusso> well, that's decidable then
<companion_cube> yeah, the type checker terminates afaik
<pgiarrusso> ocamlc just decides a typesystem that doesn't do complete inference wrt another one
<companion_cube> (aside from the exponential worst cases)
<companion_cube> yep
<pgiarrusso> yeah, the exponential worst-cases isn't too interesting
<companion_cube> it could be made faster but I think no one cares
<companion_cube> ah!! the module subtyping being undecidable? ok.
<companion_cube> I don't know enough about this corner, I'm not a type theorist :)
<pgiarrusso> re exponential, it's exponential in some N that is basically bounded by a constant
<pgiarrusso> I forget what N is, but I know I can look it up in Pierce's TAPL book
<pgiarrusso> Corbin: do you know if the CakeML people are for or against abstract machines?
<companion_cube> number of consecutive `type 'a t_i = ('a -> 'a) t_{i-1}` ?
<pgiarrusso> companion_cube: that's beyond core ML, but is similarly weird
<pgiarrusso> it might be the depth of nesting of lets, but not in a direction that humans would ever exploit...
<companion_cube> heh, fun
<Corbin> No idea about CakeML's needs. My needs involved JIT, and I've found the CAM to be very straightforward in that regard. I imagine that the CakeML folks wanted to verify security properties of the abstract machine, which sounds hard.
<companion_cube> there's a known solution though: use DAGs, not trees, in unification. But it's not important enough
<pgiarrusso> but I'm confused, that example has lets in bodies not RHSes?
<companion_cube> the exponential thing is the size of the type
<companion_cube> it's only exponential in size as a tree, not as a DAG
<companion_cube> Corbin: I imagine cakeML only compiles to native code, not sure they have a JIT
<pgiarrusso> Corbin: mostly, I'm confused because the post seems about abstract machines, but the quote doesn't mention them
bobo_ has quit [Ping timeout: 244 seconds]
spip has joined #ocaml
<pgiarrusso> in any case, "Leroy doesn't like abstract machines" might not be a showstopper. Dunno.
<pgiarrusso> I've used abstract machines, but not for any of the things he complains they don't do well
<companion_cube> maybe he liked them and moved away from them in the last 25 years
<pgiarrusso> > In every area where abstract machines help, there are arguably better alternatives: [...] Efficient execution: optimizing compilation to real machine code.
<companion_cube> there's no CAM in the IRs of ocamlopt these days, anyway
<companion_cube> nor in flambda2, which is a kind of CPS I think? or ANF, whatever that is
<pgiarrusso> is he fighting a strawman, or has somebody preferred them to compilation?
<Corbin> ANF is a kind of grammar-driven way to do CPS. It's useful in languages with typed ASTs (not Schemes), but roughly as mind-bending.
<pgiarrusso> when I was taught about them, their point was for doing metatheory, not to use them directly in the implementation
<pgiarrusso> e.g. GHC uses the Stg abstract machine as an intermediate step
<Corbin> pgiarrusso: In the ZINC paper (or maybe an earlier paper?) they talk about compiling ML by first compiling to CAM instructions, and then using a templating backend to emit native code for each instruction. This is perennial; lately I'm thinking about compiling my CAM-like bytecode to LLVM or QBE, in SSA form.
<pgiarrusso> okay, I think good compilers do some lower-level optimizations in later stages
wingsorc__ has quit [Ping timeout: 252 seconds]
<pgiarrusso> Corbin: I'm no expert but translating to LLVM and running the entire LLVM/clang optimizer seems a good first approximation
<Corbin> pgiarrusso: Sure. And that sort of thing wasn't really available back when these papers were written. So maybe there's a different effort-to-power ratio today.
<pgiarrusso> yeah
<Corbin> Like, also available today: GNU Lightning, a virtual CPU which is connected to a JIT. It's *intended* for use with that sort of templating compiler.
<pgiarrusso> I mean, abstract machine + templating should compare with GCC `-O0`, which isn't bad
<pgiarrusso> note all the hedges, since this is n-th hand experience (n = 2, 3, ...)
<pgiarrusso> :-P
<pgiarrusso> but the theoretical point of abstract machines is to explain the compilation strategy — if your source language is C, your abstract machine is just "use a stack and heap" (which isn't _that_ trivial, if you go back to when algol was invented)
<pgiarrusso> but for fancier languages, there are more interesting questions to settle :-)
<companion_cube> but no one compiles C by compiling to some abstract machine instructions, and from there
wingsorc has joined #ocaml
DNH has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xgqt has quit [Ping timeout: 246 seconds]
xgqt has joined #ocaml
omegatron has quit [Quit: Power is a curious thing.It can be contained, hidden, locked away,and yet it always breaks free.]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
waleee has quit [Ping timeout: 260 seconds]
rgrinberg has joined #ocaml
ns12 has quit [Quit: bye]
ns12 has joined #ocaml
zebrag has quit [Quit: Konversation terminated!]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Haudegen has joined #ocaml
rgrinberg has joined #ocaml
raskol has quit [Ping timeout: 240 seconds]
ansiwen has quit [Quit: ZNC 1.7.1 - https://znc.in]
ansiwen has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vicfred has quit [Quit: Leaving]
<d_bot> <net._.fri> Why are the bots having a conversation
pukkamustard has joined #ocaml
<d_bot> <darrenldl> the channel is bridged to irc
gravicappa has joined #ocaml
<d_bot> <net._.fri> ohh
Serpent7776 has joined #ocaml
gravicappa has quit [Ping timeout: 240 seconds]
pukkamustard has left #ocaml [#ocaml]
gravicappa has joined #ocaml
<octachron> pgiarrusso, typechecking OCaml is not decidable but only at the module level due to abstract module types (combined with functors).
azimut has quit [Ping timeout: 240 seconds]
cross has quit [Quit: Lost terminal]
wonko has quit [Quit: See You Space Cowboy..]
wonko- has quit [Ping timeout: 260 seconds]
Ekho has quit [Remote host closed the connection]
theblatte has quit [Ping timeout: 240 seconds]
Ekho has joined #ocaml
DNH has joined #ocaml
<gopiandcode> @net._.fri IRC users are people too fyi
genpaku has quit [Ping timeout: 272 seconds]
genpaku has joined #ocaml
<williewillus> how would I have typed "keys" each associated with a payload type, but retain the ability to store them together in collections etc.?
<williewillus> this sounds a bit abstract, so this paste demonstrates what I want a bit more https://paste.sr.ht/~williewillus/cd505299c0bce7a4db101b824535a165d7382f46
<williewillus> please ping when responding, I'm sleeping now but figured I'd ask before going off to bed
<octachron> williewillus, you can transform your GADT into an ordinary variant with an existential wrapper: `type dyn_key = Dyn: 'a key -> dyn_key [@@unboxed]`.
<williewillus> awesome, and I'd just match with | Dyn Foo and | Dyn Bar. Thanks!
sagax has joined #ocaml
<d_bot> <lubega-simon> Hi all, I would like to translate some of haskell ideas used as examples in the ‘Build Systems à la Carte’ paper to ocaml, could someone be up to help, we can begin with
<d_bot> <lubega-simon> this --
<d_bot> <lubega-simon> `data Hash v -- a compact summary of a value with a fast equality check
<d_bot> <lubega-simon> hash :: Hashable v => v -> Hash v
<d_bot> <lubega-simon> getHash :: Hashable v => k -> Store i k v -> Hash v
<d_bot> <lubega-simon> -- Build tasks (see ğ3.2)
<d_bot> <lubega-simon> newtype Task c k v = Task { run :: forall f. c f => (k -> f v) -> f v }
<d_bot> <lubega-simon> type Tasks c k v = k -> Maybe (Task c k v)`
olle has joined #ocaml
<d_bot> <octachron> You can start with a fixed corresponding `c`, and write the corresponding module type for `Task` functors.
DNH has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dh` has quit [Quit: brb]
bartholin has joined #ocaml
DNH has joined #ocaml
<d_bot> <Drup> @companion_cube do you know of bindings to SMT solvers for bitvector+linear arithemetic theories such as boolector ?
<d_bot> <Drup> alternatively, is there msat+bitv ? :p
mrd has joined #ocaml
mrd has quit [Changing host]
mrd has joined #ocaml
trev has joined #ocaml
wingsorc has quit [Ping timeout: 252 seconds]
jtm has quit [Quit: k byeeee]
jtm has joined #ocaml
omegatron has joined #ocaml
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
mbuf has joined #ocaml
bobo_ has joined #ocaml
spip has quit [Ping timeout: 256 seconds]
Haudegen has joined #ocaml
<companion_cube> no, we don't do bitvectors :(
<companion_cube> z3 does though
<companion_cube> you could also write bindings to yices2 I suppose
azimut has joined #ocaml
bobo_ has quit [Ping timeout: 272 seconds]
zebrag has joined #ocaml
<d_bot> <Drup> I would like something that doesn't break when you blow on it
<companion_cube> sadly SMT isn't there yet, I think
<companion_cube> and bitvectors are particularly fiddle (that, and floats, which are basically bitvectors)
<companion_cube> calling boolector on a smt2 file might not be the worst possibility…
<d_bot> <Drup> yeah
<d_bot> <Drup> you think boolector is the most reasonable one ?
<companion_cube> I don't know, maybe also check cvc5's results
<companion_cube> it's actively developed
<d_bot> <Drup> I have poor experiences with cvc*
<companion_cube> as in, not reliable?
<d_bot> <Drup> yes, and the frontend is fricking awful
<companion_cube> ah well
<companion_cube> they also have 10x as many devs as the other solvers, and are doing most of the innovation
<companion_cube> so I guess it's also a big research vehicule
<d_bot> <Drup> maybe they could 0.2 of those devs to make a decent frontend
<companion_cube> do you mean a better CLI? not sure what you mean there
<d_bot> <Drup> CLI/error messages/tool input-output format
<companion_cube> well the format is smtlib2, nothing much to change
<companion_cube> error messages: idk
<d_bot> <Drup> anyway
<d_bot> <Drup> I'll generate some smtlib2 formula and try stuff
waleee has joined #ocaml
waleee has quit [Ping timeout: 255 seconds]
waleee has joined #ocaml
<zozozo> for good error message on the smtlib2 synatx and typing, you can use dolmen
chrisz has quit [Quit: leaving]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
waleee has quit [Quit: WeeChat 3.5]
szkl has joined #ocaml
rgrinberg has joined #ocaml
waleee has joined #ocaml
bartholin has quit [Remote host closed the connection]
bartholin has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
waleee has quit [Ping timeout: 248 seconds]
motherfsck has joined #ocaml
waleee has joined #ocaml
DNH has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DNH has joined #ocaml
DNH has quit [Client Quit]
DNH has joined #ocaml
chrisz has joined #ocaml
vicfred has joined #ocaml
Haudegen has joined #ocaml
Sankalp has quit [Ping timeout: 246 seconds]
Sankalp has joined #ocaml
bartholin has quit [Quit: Leaving]
waleee has quit [Ping timeout: 248 seconds]
genpaku has quit [Remote host closed the connection]
waleee has joined #ocaml
genpaku has joined #ocaml
Tuplanolla has joined #ocaml
Serpent7776 has quit [Ping timeout: 240 seconds]
olle has quit [Ping timeout: 250 seconds]
genpaku has quit [Quit: leaving]
genpaku has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ns12 has quit [Quit: bye]
ns12 has joined #ocaml
mbuf has quit [Quit: Leaving]
raskol has joined #ocaml
rgrinberg has joined #ocaml
szkl has quit [Quit: Connection closed for inactivity]
olle has joined #ocaml
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
Haudegen has joined #ocaml
raskol has quit [Ping timeout: 248 seconds]
Anarchos has joined #ocaml
wingsorc has joined #ocaml
raskol has joined #ocaml
dh` has joined #ocaml
raskol has quit [Ping timeout: 246 seconds]
trev has quit [Remote host closed the connection]
azimut has quit [Ping timeout: 240 seconds]
azimut has joined #ocaml
gravicappa has quit [Ping timeout: 276 seconds]
raskol has joined #ocaml
tiferrei has quit [Ping timeout: 240 seconds]
tiferrei has joined #ocaml
adanwan_ has joined #ocaml
adanwan has quit [Ping timeout: 240 seconds]
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
olle has quit [Ping timeout: 255 seconds]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Haudegen has quit [Ping timeout: 248 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
genpaku has quit [Quit: leaving]
raskol has quit [Ping timeout: 256 seconds]
DNH has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
wingsorc__ has joined #ocaml
wingsorc has quit [Read error: Connection reset by peer]