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.]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
wingsorc has quit [Ping timeout: 260 seconds]
wingsorc has joined #ocaml
rf has quit [Remote host closed the connection]
rf has joined #ocaml
spip has quit [Quit: Konversation terminated!]
rambocoder has joined #ocaml
mbuf has joined #ocaml
waleee has quit [Ping timeout: 246 seconds]
chrisz has quit [Ping timeout: 260 seconds]
chrisz has joined #ocaml
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #ocaml
trillion_exabyte has quit [Ping timeout: 248 seconds]
trillion_exabyte has joined #ocaml
rf has quit [Quit: Leaving]
<discocaml> <tautologico> can I memory map `Unix.stdout` and `Unix.stderr`?
trev has joined #ocaml
<discocaml> <tautologico> I just tried, doesn't seem to work
wilfred has joined #ocaml
rambocoder has quit [Quit: Connection closed for inactivity]
hackinghorn has joined #ocaml
hackinghorn has quit [Remote host closed the connection]
hackinghorn has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
Haudegen has joined #ocaml
bgs has joined #ocaml
hackhorn has joined #ocaml
hackinghorn has quit [Ping timeout: 248 seconds]
mro has joined #ocaml
Serpent7776 has joined #ocaml
Serpent7776 has quit [Ping timeout: 248 seconds]
bartholin has joined #ocaml
bartholin has quit [Quit: Leaving]
mro has quit [Remote host closed the connection]
Serpent7776 has joined #ocaml
mro has joined #ocaml
spip has joined #ocaml
wilfred has quit [Quit: Connection closed for inactivity]
<discocaml> <Et7f3 (@me on reply)> What do you intend to do ?
<discocaml> <Et7f3 (@me on reply)> You launched with or without redirection to file ?
olle has joined #ocaml
dhil has joined #ocaml
neiluj has joined #ocaml
<neiluj> hi! is it easy to flip a bit of a byte sequence?
<neiluj> trying something with Bytes.get/set and Char.code
<olle> One bit?
<neiluj> yes!
<neiluj> maybe get an int, increment it, then set would be better
<discocaml> <masterbuilder> neiluj: create a bitmask with the bit you're interested set and then xor the original value with that bitmask
<discocaml> <Marc> I'd like to convert projects using the raylib library to work in the browser. raylib is working perfectly fine with a C program compiled via emscripten, but for OCaml I have no clue on what I'd need to do to compile with js_of_ocaml and have a working application in the browser. Has someone any pointers or ideas to help me?
<neiluj> oh nice thanks for the input! bitmask is great!
<neiluj> thanks olle too :)
<olle> neiluj: Feel free to add a new answer to the SO thread, it was top google result
mro_ has joined #ocaml
mro has quit [Ping timeout: 268 seconds]
azimut has joined #ocaml
hornhack has joined #ocaml
hornhack has quit [Remote host closed the connection]
hackhorn has quit [Ping timeout: 248 seconds]
mro_ has quit [Remote host closed the connection]
mro has joined #ocaml
riverdc has quit [Quit: quitting]
riverdc has joined #ocaml
anpad has quit [Quit: ZNC 1.8.2 - https://znc.in]
anpad has joined #ocaml
Serpent7776 has quit [Ping timeout: 255 seconds]
Serpent7776 has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
wingsorc has quit [Quit: Leaving]
gwizon has quit [Quit: Lost terminal]
infinity0 has quit [Ping timeout: 252 seconds]
infinity0 has joined #ocaml
Haudegen has joined #ocaml
dhil has quit [Ping timeout: 248 seconds]
dnh has joined #ocaml
rf has joined #ocaml
mro has quit [Quit: Leaving...]
szkl has quit [Quit: Connection closed for inactivity]
mbuf has quit [Quit: Leaving]
dhil has joined #ocaml
Serpent7776 has quit [Quit: WeeChat 1.9.1]
<discocaml> <zbaylin> ```ocaml
<discocaml> <zbaylin> Is there any way of specifying first class module arguments that implement multiple module types without defining a new one? i.e.
<discocaml> <zbaylin> module type S0 = sig ... end
<discocaml> <zbaylin> module type S1 = sig ... end
<discocaml> <zbaylin>
<discocaml> <zbaylin> let f (module M : sig include S0 include S1 end) = ...
<discocaml> <zbaylin> ```
<discocaml> <zbaylin> That example doesn't compile, but it would be nice to not have to create multiple new interfaces
<discocaml> <KW78> how so ?
<discocaml> <KW78> ```ocaml
<discocaml> <KW78> # module type S0 = sig type t = int val tx : t end;;
<discocaml> <KW78> module type S0 = sig type t = int val tx : t end
<discocaml> <KW78> # module type S1 = sig type u = string val ux : u end;;
<discocaml> <KW78> module type S1 = sig type u = string val ux : u end
<discocaml> <KW78> # module type S01 = sig include S0 include S1 end;;
<discocaml> <KW78> module type S01 = sig type t = int val tx : t type u = string val ux : u end
<discocaml> <KW78> # let f (module M: S01) = M.tx, M.ux;;
<discocaml> <KW78> val f : (module S01) -> int * string = <fun>
<discocaml> <KW78> ```
<discocaml> <KW78> I am not sure if you can build an anonymous module type though directly
<discocaml> <octachron> You can't, packed module types must be named to avoid introducing the whole module expression language into the type expression ones.
<discocaml> <KW78> make sense wrt the error message `Error: Invalid package type: only module type identifier and 'with type' constraints are supported`
Haudegen has quit [Quit: Bin weg.]
<discocaml> <tautologico> I'm running a program and want to get its output, I wondered if I could get the contents in a buffer instead of writing to a file then reading the file. I think it's possible if I create a file, mmap it, then redirect stdout/err to it with sharing disabled, but it still creates the file
azimut has quit [Ping timeout: 255 seconds]
azimut has joined #ocaml
neiluj has quit [Quit: WeeChat 3.6]
<discocaml> <lagarto> @tautologico I see Unix.open_process_in in the stdlib, is that what you want?
<discocaml> <tautologico> almost. I don't want to run the program in parallel, I want to run it to completion and then look at the output
<discocaml> <lagarto> can't you just block reading the channel till you get EOF?
<discocaml> <tautologico> maybe
<discocaml> <Cherry 🍒> largato 👆
<discocaml> <Cherry 🍒> paraguaio 🦜
<discocaml> <Et7f3 (@me on reply)> Mmap won't auto expand memory so it should not be part of the solution. Usually IPC is done through pipe (command substitution in bash use that). If pipe solution interest you then go with lagarto' solution or Unix.open_process_args_in (to get a little speed boost)
<discocaml> <Et7f3 (@me on reply)> ?
<discocaml> <Et7f3 (@me on reply)> Is it a program you own ?
<discocaml> <tautologico> I think it's simpler to use files 🙂
<discocaml> <Et7f3 (@me on reply)> They have the same API
<discocaml> <tautologico> it's not anything critical
<discocaml> <Cherry 🍒> ? what
<discocaml> <tautologico> lagarto: 🦎 papagaio: 🦜
<discocaml> <Et7f3 (@me on reply)> You typically choose file for persistence and pipe for IPC
Tuplanolla has joined #ocaml
<discocaml> <tautologico> yeah it's probably the best solution. thanks @Et7f3 @lagarto
<discocaml> <tautologico> (I also need to set the environment so I guess I need `open_process_full` even if I don't need to use stdin)
Haudegen has joined #ocaml
<discocaml> <GodFather> hi I m trying to solve this twistTree problem but it seems to me that I m missing something. Can someone help me understand what I m doing wrong? Code and question below
<discocaml> <GodFather>
<discocaml> <GodFather> Define twistTree that twists the data around the tree without changing the branching structure. Here are some example inputs and outputs:
<discocaml> <GodFather>
<discocaml> <GodFather> twistTree (Branch (Branch (Leaf 1, 2, Leaf 3), 4, Branch (Leaf 5, 6, Leaf 7))) = (Branch (Branch (Leaf 3, 5, Leaf 2), 1, Branch (Leaf 7, 4, Leaf 6)))
<discocaml> <GodFather>
<discocaml> <GodFather> twistTree (Branch (Leaf 3, 1, Branch (Leaf 4, 2, Leaf 5))) = (Branch (Leaf 4, 3, Branch (Leaf 5, 1, Leaf 2)))
<discocaml> <GodFather>
<discocaml> <GodFather> Hint: Draw the input and output trees in graphical form.
<discocaml> <GodFather> ```
<discocaml> <GodFather> type 'a tree =
<discocaml> <GodFather> | Leaf of 'a
<discocaml> <GodFather> | Branch of 'a tree * 'a * 'a tree
<discocaml> <GodFather> let rec twistTree (tree : 'a tree) : 'a tree =
<discocaml> <GodFather> match tree with
<discocaml> <GodFather> | Leaf x -> Leaf x
<discocaml> <GodFather> | Branch (left, x, right) ->
<discocaml> <GodFather> let newLeft = twistTree right in
<discocaml> <GodFather> let newRight = twistTree left in
<discocaml> <GodFather> Branch (newLeft, x, newRight)
<discocaml> <GodFather> ```
<technomancy> >_<
<discocaml> <GodFather> hi I m trying to solve this twistTree problem but it seems to me that I m missing something. Can someone help me understand what I m doing wrong? My Code and question below
<discocaml> <GodFather>
<discocaml> <GodFather> Define twistTree that twists the data around the tree without changing the branching structure. Here are some example inputs and outputs:
<discocaml> <GodFather>
<discocaml> <GodFather> twistTree (Branch (Branch (Leaf 1, 2, Leaf 3), 4, Branch (Leaf 5, 6, Leaf 7))) = (Branch (Branch (Leaf 3, 5, Leaf 2), 1, Branch (Leaf 7, 4, Leaf 6)))
<discocaml> <GodFather>
<discocaml> <GodFather> twistTree (Branch (Leaf 3, 1, Branch (Leaf 4, 2, Leaf 5))) = (Branch (Leaf 4, 3, Branch (Leaf 5, 1, Leaf 2)))
<discocaml> <GodFather>
<discocaml> <GodFather> Hint: Draw the input and output trees in graphical form.
<discocaml> <GodFather> ```
<discocaml> <GodFather> type 'a tree =
<discocaml> <GodFather> | Leaf of 'a
<discocaml> <GodFather> | Branch of 'a tree * 'a * 'a tree
<discocaml> <GodFather> let rec twistTree (tree : 'a tree) : 'a tree =
<discocaml> <GodFather> match tree with
<discocaml> <GodFather> | Leaf x -> Leaf x
<discocaml> <GodFather> | Branch (left, x, right) ->
<discocaml> <GodFather> let newLeft = twistTree right in
<discocaml> <GodFather> let newRight = twistTree left in
<discocaml> <GodFather> Branch (newLeft, x, newRight)
<discocaml> <GodFather> ```
<discocaml> <hockletock> I can see that your code leaves a branch's 'a value alone but in the last example your branch values are 1 and 2 but becomes 3 and 1
<technomancy> I guess the discord bridge doesn't understand how pastebins work huh
<technomancy> yikes dot gif
<discocaml> <hockletock> yeah if youwant to post code blocks do it in #beginners
<discocaml> <GodFather> mb, didnt know you have to post it in
<discocaml> <GodFather> mb, didnt know you have to post it in beginners
<technomancy> why not bridge discord to matrix and then bridge that to libera? then you'd get nicks that actually work and stuff
<discocaml> <GodFather> can you explain this more?
<technomancy> well like ... matrix has bridging that actually works, right?
<technomancy> matrix users are represented as distinct nicks
<technomancy> and long code samples get automatically turned into pastebin links
<technomancy> matrix bridges to libera but it also supposedly supports bridging to discord (never used this because I stay the hell away from discord, but so I'm told)
<technomancy> I'm guessing their discord bridge would similarly represent distinct users as distinct, so it doesn't break all the features that rely on users having nicks
<discocaml> <NULL> (That question was directed to hockletock)
<technomancy> I've been in multiple channels that more or less disintegrated when the discord bridge got activated because it just doesn't work evry well
dhil has quit [Ping timeout: 255 seconds]
<discocaml> <hockletock> @GodFather look at the lastexample. ([3] {1} ([4] {2} [5])) becomes ([4] {3} ([5] {1} [2]))
<discocaml> <hockletock> apologies for the horrible brackets but {} are values in the "middle" of branches
<discocaml> <hockletock> Your code leaves those intact, branch \_ x \_ becomes branch \_ x \_
<discocaml> <hockletock> their example shows that that's not consistent with their definition of "twisting"
dhil has joined #ocaml
waleee has joined #ocaml
<technomancy> ohhhhh lol ok yeah
oriba has joined #ocaml
kurfen has joined #ocaml
micro has quit [Ping timeout: 255 seconds]
micro has joined #ocaml
azimut_ has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
bartholin has joined #ocaml
<discocaml> <GodFather> yea I'm not able to fix the code. Can you give me a hint to the right direction
<discocaml> <GodFather> @hockletock yea I'm not able to fix the code. Can you give me a hint to the right direction
<discocaml> <GodFather> @hockletock yea I'm not able to fix the code. Can you give me a hint to the right direction code wise
Stumpfenstiel has joined #ocaml
olle has quit [Ping timeout: 260 seconds]
trev has quit [Remote host closed the connection]
dhil has quit [Ping timeout: 268 seconds]
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
masterbuilder has joined #ocaml
m5zs7k has quit [Ping timeout: 264 seconds]
m5zs7k has joined #ocaml
Stumpfenstiel has quit [Ping timeout: 268 seconds]
dnh has quit [Quit: Textual IRC Client: www.textualapp.com]
bartholin has quit [Quit: Leaving]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
habnabit has quit [Quit: ZNC - http://znc.sourceforge.net]
habnabit_ has joined #ocaml
azimut_ has quit [Remote host closed the connection]
azimut has joined #ocaml
oriba has joined #ocaml
Haudegen has quit [Ping timeout: 255 seconds]