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/
Tuplanolla has quit [Quit: Leaving.]
spip has quit [Quit: Konversation terminated!]
azimut_ has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
chrisz has quit [Ping timeout: 252 seconds]
chrisz has joined #ocaml
<discocaml> <darrenldl> is there a format syntax/option where it keeps track of the width of the box instead of only just the indentation?
<discocaml> <darrenldl> (`Format` or `Fmt`)
waleee has quit [Ping timeout: 260 seconds]
<companion_cube> what would that look like?
<discocaml> <val patate: unit Lazy.t> can one define a type's array-like initialisation (`[| x1; ...; xn |]`) ?
mbuf has joined #ocaml
<discocaml> <val patate: unit Lazy.t> I think I saw somewhere that you could include a module, and `[| x1; ... xn |]`, but can't remember... maybe it's just me hallucinating
<discocaml> <val patate: unit Lazy.t> I think I saw somewhere that you could include a module, and `[| x1; ... xn |]` would then work on it, but can't remember... maybe it's just me hallucinating
<discocaml> <val patate: unit Lazy.t> One can do `module Array = struct let get = List.nth end` to shadow `.()` then use it on lists: `[1; 2; 3].(1)`... But is there something similar with initialisation?
adanwan has quit [Ping timeout: 255 seconds]
adanwan has joined #ocaml
trev has joined #ocaml
ansiwen_ has quit [Quit: ZNC 1.7.1 - https://znc.in]
ansiwen has joined #ocaml
Haudegen has joined #ocaml
<discocaml> <darrenldl> companion_cube: i probably phrased that poorly, but basically say within a box, i print a list of strings, followed by say a closing bracket:
<discocaml> <darrenldl>
<discocaml> <darrenldl> `Fmt.pr "[ @[<hv>%a@] ]" Fmt.(list string) some_strings`
<discocaml> <darrenldl>
<discocaml> <darrenldl> i just wonder what would be the easiest to make the closing bracket to be "right alinged"
<discocaml> <darrenldl> so instead of
<discocaml> <darrenldl> ```
<discocaml> <darrenldl> [ abcd
<discocaml> <darrenldl> de ]
<discocaml> <darrenldl> ```
<discocaml> <darrenldl>
<discocaml> <darrenldl> it would be
<discocaml> <darrenldl>
<discocaml> <darrenldl> ```
<discocaml> <darrenldl> [ abcd
<discocaml> <darrenldl> de ]
<discocaml> <darrenldl> ```
<discocaml> <darrenldl> (outside of calculating the padding myself)
bartholin has joined #ocaml
adanwan has quit [Ping timeout: 255 seconds]
adanwan has joined #ocaml
<whereiseveryone> what's a good book for learning how to write a toy lang with ocaml by hand?
<whereiseveryone> aka without a yacc parser generator thingy
trillion_exabyte has quit [Ping timeout: 268 seconds]
<whereiseveryone> pukkamustard: what emacs ocaml packages for development do you use and do you install them all with the guix package manager?
infinity0 has quit [*.net *.split]
rf has quit [*.net *.split]
qxz2 has quit [*.net *.split]
asm has quit [*.net *.split]
rom1504 has quit [*.net *.split]
noze` has quit [*.net *.split]
tizoc has quit [*.net *.split]
brettgilio has quit [*.net *.split]
dme2_ has quit [*.net *.split]
ocabot_ has quit [*.net *.split]
technomancy has quit [*.net *.split]
towel_ has quit [*.net *.split]
Ekho has quit [*.net *.split]
kronicma1 has quit [*.net *.split]
companion_cube has quit [*.net *.split]
drewolson has quit [*.net *.split]
brettgilio has joined #ocaml
rom1504 has joined #ocaml
rf has joined #ocaml
infinity0 has joined #ocaml
tizoc has joined #ocaml
qxz2 has joined #ocaml
dme2_ has joined #ocaml
noze` has joined #ocaml
asm has joined #ocaml
ocabot_ has joined #ocaml
towel_ has joined #ocaml
kronicma1 has joined #ocaml
drewolson has joined #ocaml
companion_cube has joined #ocaml
technomancy has joined #ocaml
Ekho has joined #ocaml
trillion_exabyte has joined #ocaml
<discocaml> <val patate: unit Lazy.t> why would you want to not use yacc/menhir/camllex?
Serpent7776 has joined #ocaml
tizoc has quit [Ping timeout: 248 seconds]
spip has joined #ocaml
tizoc has joined #ocaml
Serpent7776 has quit [Ping timeout: 256 seconds]
bartholin has quit [Quit: Leaving]
<discocaml> <psychokitty> There's the LLVM "Kaleidoscope" language tutorial which doesn't use menhir or ocamlyacc.
kakadu has joined #ocaml
spip has quit [Quit: Konversation terminated!]
azimut_ has quit [Ping timeout: 255 seconds]
adanwan_ has joined #ocaml
adanwan has quit [Quit: _]
gahr_ has joined #ocaml
olle has joined #ocaml
gahr has quit [Ping timeout: 255 seconds]
ks_ has quit [Ping timeout: 268 seconds]
ks_ has joined #ocaml
Serpent7776 has joined #ocaml
<discocaml> <Kakadu> Where caml_apply2/3 is linked from? I tried to objdump -t libasmrun.a but it is undefined there...
<discocaml> <Kakadu> As background, I'm wondering could I override caml_apply2/3 to use high bits of the pointer for tagging...
<zozozo> @kakadu: the caml_applyN functions are generated by ocamlopt and part of the emitted assembly code
rf has quit [Remote host closed the connection]
rf has joined #ocaml
<discocaml> <octachron> @BigOof Format doesn't record the width of boxes, so that doesn't seem possible in general.
<discocaml> <darrenldl> gotcha, thanks! i was guessing that'd be the case for complexity and performance reasons, but just wanted to make sure im not missing some obvious api
<discocaml> <bnguyenv> Probably possible with PPrint, using align: http://cambium.inria.fr/~fpottier/pprint/doc/pprint/
<discocaml> <darrenldl> ooo
<discocaml> <darrenldl> thanks for pointer
<discocaml> <bnguyenv> Oh no I think you could only have the ending parenthesis on a newline by itself actually
<discocaml> <bnguyenv> Trying to play with it a bit, I can't manage to get even that, so maybe not sorry...
<discocaml> <darrenldl> ooo, thanks for the update!
<discocaml> <darrenldl>
<discocaml> <darrenldl> tbh this need is very niche, and wouldnt make sense to be in a api that targets general use
olle has quit [Ping timeout: 248 seconds]
mro has joined #ocaml
spip has joined #ocaml
olle has joined #ocaml
hackinghorn has joined #ocaml
anpad has quit [Read error: Connection reset by peer]
anpad has joined #ocaml
<discocaml> <Oégua> hey guys, I'm having a little bit of a problem to make my VSCode recongnize the Zarith library (i'm using the OCaml Platform extension)
<companion_cube> @darrenldl oh, tough
rf has quit [Remote host closed the connection]
rf has joined #ocaml
masterbuilder has quit [Ping timeout: 248 seconds]
masterbuilder has joined #ocaml
rf has quit [Remote host closed the connection]
rf has joined #ocaml
<discocaml> <darrenldl> companion_cube: yeah, this is only just for a small note finding tool i use for myself though, and i don't care enough to pad it properly anyway : D
masterbuilder has quit [Ping timeout: 248 seconds]
masterbuilder has joined #ocaml
mro_ has joined #ocaml
mro has quit [Ping timeout: 248 seconds]
mro_ has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
Haudegen has quit [Quit: Bin weg.]
gahr_ is now known as gahr
chrisz has quit [Ping timeout: 260 seconds]
chrisz has joined #ocaml
<discocaml> <∆V> I want to manually create a call to an external function in OCaml's lambda IR and use OCaml's backend to compile that, but the arguments are not being passed correctly.
<discocaml> <∆V> I've manually generated this lambda expression: `(seq (apply (function (nat_foo)) 255) 0a)`.
<discocaml> <∆V> Which compiles to the following cmm: ```lisp
<discocaml> <∆V> (data int 768 global "camlTest" "camlTest":)
<discocaml> <∆V> (data
<discocaml> <∆V> global "camlTest__gc_roots"
<discocaml> <∆V> "camlTest__gc_roots":
<discocaml> <∆V> addr "camlTest"
<discocaml> <∆V> int 0)
<discocaml> <∆V> (function camlTest__fun_81 () (extcall "nat_foo" val))
<discocaml> <∆V>
<discocaml> <∆V> (data int 3063 "camlTest__1": addr "camlTest__fun_81" int 1)
<discocaml> <∆V> (function camlTest__entry ()
<discocaml> <∆V> (app (load_mut val "camlTest__1") 511 "camlTest__1" unit) 1a)
<discocaml> <∆V>
<discocaml> <∆V> (data)```
<discocaml> <∆V> But the following c function:```c
<discocaml> <∆V> CAMLprim value nat_foo(value arg) {
<discocaml> <∆V> printf("foo called with %d!\n", Int_val(arg));
<discocaml> <∆V> return Val_unit;
<discocaml> <∆V> }```prints `foo called with 1500117184!`.
<discocaml> <∆V> I use `ocamlopt` to generate a single object file (without the runtime) and I have no issues linking it. So what's going wrong here?
<discocaml> <∆V> I want to manually create a call to an external function in OCaml's lambda IR and use OCaml's backend to compile that, but the arguments are not being passed correctly.
<discocaml> <∆V> I've manually generated this lambda expression: `(seq (apply (function (nat_foo)) 255) 0a)`.
<discocaml> <∆V> Which compiles to the following cmm: ```lisp
<discocaml> <∆V> (data int 768 global "camlTest" "camlTest":)
<discocaml> <∆V> (data
<discocaml> <∆V> global "camlTest__gc_roots"
<discocaml> <∆V> "camlTest__gc_roots":
<discocaml> <∆V> addr "camlTest"
<discocaml> <∆V> int 0)
<discocaml> <∆V> (function camlTest__fun_81 () (extcall "nat_foo" val))
<discocaml> <∆V>
<discocaml> <∆V> (data int 3063 "camlTest__1": addr "camlTest__fun_81" int 1)
<discocaml> <∆V> (function camlTest__entry ()
<discocaml> <∆V> (app (load_mut val "camlTest__1") 511 "camlTest__1" unit) 1a)
<discocaml> <∆V>
<discocaml> <∆V> And -assuming I just did the generation of the lambda expression wrong- how could I go about correctly generating such a call?
azimut has joined #ocaml
azimut has quit [Remote host closed the connection]
<discocaml> <∆V> And -assuming I just did the generation of the lambda expression wrong- how could I go about correctly generating such a call?
<discocaml> <∆V> (If it's of any relevance, I'm trying to write a fork of Malfunction that supports calling external functions)
azimut has joined #ocaml
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #ocaml
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
<discocaml> <octachron> The cmm calls your function on some undefined `val` value? Also your `Lfunction` looks strange?
<discocaml> <octachron> Translating
<discocaml> <octachron> ```ocaml
<discocaml> <octachron> external myx: int -> int -> unit = "myx"
<discocaml> <octachron> let () = myx 255 256
<discocaml> <octachron> ```
<discocaml> <octachron> yields
<discocaml> <octachron> ```
<discocaml> <octachron> (seq (let (*match*/272 = (seq (myx 255 256) 0)) 0) 0)
<discocaml> <octachron> ```
<discocaml> <∆V> I discovered the same, hence I assume I'm just doing something fundamentally wrong. How do you suggest I do it?
<discocaml> <∆V> Btw, I'm pretty sure `val` is just short for any literal value. It appears in all my tested cmm multiple times where you'd expect literals.
<discocaml> <octachron> Don't generate an anonymous function when you intended to call an existing function?
<discocaml> <∆V> But the called function is defined externally?
<discocaml> <∆V> Should i just generate a call to an undefined function "nat_foo"?
Haudegen has joined #ocaml
<discocaml> <octachron> As far as I understand, by the time that you call the function, it needs to have been resolved to some symbol, independently on where the function was defined.
<discocaml> <∆V> You mean that which is added to the environment by the `external nat_foo` declaration?
<discocaml> <∆V> The `Types.value_description`?
<discocaml> <octachron> Types don't exist at runtime, if you are generating lambda you should ignore them.
<discocaml> <∆V> So you're saying that I should just `Lapply nat_foo` basically?
mro has joined #ocaml
mro has quit [Remote host closed the connection]
<discocaml> <octachron> Yes
<discocaml> <∆V> I'll give it a try!
kurfen has quit [Ping timeout: 268 seconds]
<discocaml> <∆V> @octachron as expected: `Fatal error: Selection.emit_expr: unbound var nat_foo`
<discocaml> <∆V> But this is the lambda and cmm, if i follow ur instructions: ```
<discocaml> <∆V> lambda:
<discocaml> <∆V> (seq (apply nat_foo! 255) 0a)
<discocaml> <∆V>
<discocaml> <∆V> cmm:
<discocaml> <∆V> (data int 768 global "camlTest" "camlTest":)
<discocaml> <∆V> (data
<discocaml> <∆V> global "camlTest__gc_roots"
<discocaml> <∆V> "camlTest__gc_roots":
<discocaml> <∆V> addr "camlTest"
<discocaml> <∆V> int 0)
<discocaml> <∆V> (function camlTest__entry ()
<discocaml> <∆V> (app (load_mut val nat_foo!) 511 nat_foo! unit) 1a)```
<discocaml> <∆V> Is the fact that it's applying a problem?
<discocaml> <∆V> Is the fact that it's `apply`ing a problem?
kurfen has joined #ocaml
<discocaml> <∆V> Oh
<discocaml> <∆V> wait
<discocaml> <∆V> I solved it!
<discocaml> <∆V> I just add the function as a global primitive to the environment and the rest just works out of the box!
<discocaml> <∆V> Thanks for the help! :))
<discocaml> <octachron> Not sure if I add helped much (but yes within `nat_foo!` the `!` means that `nat_foo` is a global (and unique) identifier).
<discocaml> <octachron> Not sure if I have helped much (but yes within `nat_foo!` the `!` means that `nat_foo` is a global (and unique) identifier).
<discocaml> <∆V> Turns out that it indeed needed to be a global yea
hackinghorn has quit [Ping timeout: 248 seconds]
mischief has joined #ocaml
<mischief> is it possible to pass configure flags to packages installed by opam?
<companion_cube> https://github.com/ocaml/ocaml/pull/12006 man, very nice
<mischief> to answer my own question, the answer appears to be no.. opam configure flags appear to be fixed inside the build script with no escape hatch.
bartholin has joined #ocaml
mbuf has quit [Quit: Leaving]
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
terrorjack has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
<discocaml> <cemerick> companion_cube: in the category of, "I didn't even know I wanted it"
Serpent7776 has quit [Quit: WeeChat 1.9.1]
dhil has joined #ocaml
waleee has joined #ocaml
Tuplanolla has joined #ocaml
Haudegen has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
wingsorc has joined #ocaml
masterbuilder has quit [Quit: leaving]
mro has quit [Read error: Connection reset by peer]
mro_ has joined #ocaml
masterbuilder has joined #ocaml
Stumpfenstiel has joined #ocaml
mro_ has quit [Remote host closed the connection]
mro has joined #ocaml
olle has quit [Ping timeout: 248 seconds]
<discocaml> <lukstafi> Hi! Has anyone experienced weird file IO behavior from within `%expect_test` code? For me, the output just does not appear in the file, and I made sure to flush often, verified that things get output if the channel is `stdout` (in the `Trailing output` section), and that the file is populated if the same code is run from a `dune exec` binary. (The code raises an exception, that is uncaught if run as `dune exec`.)
trev has quit [Remote host closed the connection]
dhil has quit [Ping timeout: 248 seconds]
bartholin has quit [Quit: Leaving]
bgs has quit [Remote host closed the connection]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
sparogy has quit [Remote host closed the connection]
sparogy has joined #ocaml
mro has quit [Quit: Leaving...]
azimut has quit [Ping timeout: 255 seconds]
azimut has joined #ocaml
dnh has joined #ocaml
dnh has quit [Client Quit]