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/
afon has left #ocaml [#ocaml]
eight has quit [Read error: Connection reset by peer]
zebrag has quit [Quit: Konversation terminated!]
eight has joined #ocaml
eight has quit [Client Quit]
vicfred has quit [Ping timeout: 264 seconds]
<xenu> why is the native compiler named 'ocamlopt'? what does 'opt' stand for?
<dstolfa> i'd assume "optimizing compiler"
<dstolfa> or something along those lines...
<companion_cube> I think so, yes
dh` has quit [Ping timeout: 272 seconds]
dh` has joined #ocaml
noddy has quit [Ping timeout: 272 seconds]
noddy has joined #ocaml
vsiles has quit [Ping timeout: 272 seconds]
vsiles has joined #ocaml
nore has quit [Ping timeout: 272 seconds]
nore has joined #ocaml
Ekho has quit [Ping timeout: 272 seconds]
Ekho has joined #ocaml
vb has quit [Ping timeout: 272 seconds]
vb has joined #ocaml
eight has joined #ocaml
pippijn has quit [Ping timeout: 272 seconds]
pippijn has joined #ocaml
ralu has quit [Ping timeout: 272 seconds]
ralu has joined #ocaml
mbuf has joined #ocaml
_13h has joined #ocaml
_13h has left #ocaml [#ocaml]
osa1 has quit [Ping timeout: 272 seconds]
zodeishi has quit [Ping timeout: 264 seconds]
unyu has quit [Ping timeout: 245 seconds]
vicfred has joined #ocaml
unyu has joined #ocaml
shawnw has quit [Ping timeout: 272 seconds]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
Haudegen has joined #ocaml
bartholin has joined #ocaml
vb has quit [Ping timeout: 244 seconds]
vb has joined #ocaml
sadiq has quit [Ping timeout: 272 seconds]
sadiq has joined #ocaml
olle_ has joined #ocaml
dhil has joined #ocaml
vicfred has quit [Quit: Leaving]
noisy-bot has joined #ocaml
mbuf has quit [Quit: Leaving]
olle has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
bartholin has quit [Ping timeout: 252 seconds]
bartholin has joined #ocaml
Guest3263 has quit [Ping timeout: 245 seconds]
kakadu has joined #ocaml
kakadu has quit [Ping timeout: 245 seconds]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
wonko has quit [Ping timeout: 264 seconds]
swarm has joined #ocaml
waleee has joined #ocaml
olle_ has quit [Remote host closed the connection]
olle has quit [Remote host closed the connection]
zodeishi has joined #ocaml
Haudegen has joined #ocaml
olle has joined #ocaml
mro has quit [Remote host closed the connection]
swarm has quit [Ping timeout: 250 seconds]
unyu has quit [Ping timeout: 244 seconds]
unyu has joined #ocaml
waleee has quit [Ping timeout: 272 seconds]
waleee has joined #ocaml
mbuf has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 252 seconds]
labor[m] has quit [Quit: node-irc says goodbye]
krnkktz has quit [Quit: node-irc says goodbye]
Sumera[m] has quit [Quit: node-irc says goodbye]
radiopotin[m] has quit [Quit: node-irc says goodbye]
smondet[m] has quit [Quit: node-irc says goodbye]
fluxm has quit [Quit: node-irc says goodbye]
<EmoSpice> I'm attempting to write raw bytes to an out_channel. Using Printf.fprintf seems appropriate, but is lacking a bytes specific specifier. I come specifically from a Python background where this difference between Bytes and String as types means a lot more and I'm worried about encodings being applied during conversion. The docs state that the only
<EmoSpice> difference is that String is immutable. Am I worried for nothing?
olle has quit [Ping timeout: 245 seconds]
<companion_cube> there is no difference indeed, OCaml won't change encodings behind your back
<octachron> Yes. The OCaml compiler doesn't try to fail at handling unicode. There will be no conversion applied behind your back.
<companion_cube> however it is true that there is no specifier for bytes
<octachron> `pp_print_bytes` should be in 4.13.0
<companion_cube> ugh so I need to add it to containers now? :po
<companion_cube> :p
<EmoSpice> I'm fine with converting to string for this. Thanks!
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Client Quit]
labor[m] has joined #ocaml
krnkktz has joined #ocaml
fluxm has joined #ocaml
smondet[m] has joined #ocaml
Sumera[m] has joined #ocaml
radiopotin[m] has joined #ocaml
<companion_cube> @darrendl lol, good luck with to.ml
mro has joined #ocaml
Tuplanolla has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
cedric has joined #ocaml
tane has joined #ocaml
mbuf has quit [Quit: Leaving]
vicfred has joined #ocaml
<d_bot> <darrenldl> companion_cube: in what sense : D ?
<companion_cube> it's a bit of a cursed library, imho :p
<companion_cube> some many versions, never a stable API
<d_bot> <darrenldl> (googling whether i can uncomment gh issue secretly)
mro has quit [Quit: Leaving...]
<d_bot> <darrenldl> i mean it seems to have similar style of internal wrangling of date time to ISO8601.ml, so maybe possibly manageable
Haudegen has joined #ocaml
rak has quit [Quit: Segmentation fault (core dumped)]
rak has joined #ocaml
waleee has quit [Ping timeout: 244 seconds]
noisy-bot has quit [Ping timeout: 252 seconds]
bartholin has quit [Quit: Leaving]
TheLemonMan has joined #ocaml
romildo has joined #ocaml
romildo has quit [Client Quit]
romildo has joined #ocaml
<romildo> How would be a simple and most portable way of getting the current year in OCaml? Preferably without using alternative standard libraries.
<companion_cube> without libraries it's not trivial (you could use `Unix` but it's not the prettiest API)
<romildo> It could use a small library. But I would like to avoid big libraries like Core for instance.
<companion_cube> look at timedesc then
<companion_cube> not sure it's that small, but it's more modern
<smondet[m]> then https://erratique.ch/software/ptime solves most common time-related problem
<smondet[m]> * then https://erratique.ch/software/ptime solves most common time-related problems
<companion_cube> it gives you the year?
<smondet[m]> (you get the date from `Unix.gettimeofday` and them manipulate it with ptime toget the year or anything)
<companion_cube> ah yes, nvm
<companion_cube> Ptime_clock.now
<smondet[m]> (eg `Ptime.of_date_time` )
<companion_cube> + Ptime.to_date_time;;
<companion_cube> smondet[m]: ptime has its own clock anyway
<zozozo> the Unix module has some functions (see the type `tm` and functions `gmtime`)
<smondet[m]> companion_cube: ah indeed in the other library ptime.clock
<companion_cube> ptime.clock.os in particular
<companion_cube> zozozo: but these are horrible
fluxm has quit [Ping timeout: 244 seconds]
smondet[m] has quit [Ping timeout: 272 seconds]
labor[m] has quit [Ping timeout: 244 seconds]
radiopotin[m] has quit [Ping timeout: 272 seconds]
Sumera[m] has quit [Ping timeout: 272 seconds]
<zozozo> companion_cube: probably, ^^
<companion_cube> :p
<companion_cube> it's not worth it, just use ptime, tbh
<romildo> Thanks for the tips. I will try ptime.
<romildo> How to start a toplevel session with the ptime module opened?
<companion_cube> from inside you can use `#require "ptime.clock.os";;`
<companion_cube> after `#use "topfind";;`
<companion_cube> (that can also go in ~/.ocamlinit)
waleee has joined #ocaml
nyuhu has joined #ocaml
<d_bot> <mimoo> so, what's the idiomatic way in ocaml to do "start from idx 0 or 1 depending on some bool, then go from idx to idx + 5, then go from idx + 5 + 1 to idx + 5 + 1 + 8, etc."
<d_bot> <mimoo> I wrote something pretty ugly:
<d_bot> <mimoo>
<d_bot> <mimoo> ```
<d_bot> <mimoo> let constant_offset = if ... then 1 else 0 in
<d_bot> <mimoo> let range = (constant_offset, constant_offset + a) in
<d_bot> <mimoo> for i = fst range to snd range do ... done;
<d_bot> <mimoo> let range = (snd range + 1, snd range + 1 + b) in
<d_bot> <mimoo> ...
<d_bot> <mimoo> ```
romildo has quit [Quit: Leaving]
berberman has quit [Quit: ZNC 1.8.2 - https://znc.in]
favonia has quit [Remote host closed the connection]
favonia has joined #ocaml
favonia has quit [Ping timeout: 245 seconds]
favonia has joined #ocaml
berberman has joined #ocaml
krnkktz has quit [Quit: Bridge terminating on SIGTERM]
labor[m] has joined #ocaml
krnkktz has joined #ocaml
fluxm has joined #ocaml
radiopotin[m] has joined #ocaml
smondet[m] has joined #ocaml
Sumera[m] has joined #ocaml
<d_bot> <Christophe> I have issues understanding what kind of logic could justify having to write this 🤔
<d_bot> <Christophe> I think that instead of encoding the range with [start; last] i would encode it as [start ; start + size -1], if it's clear. Also, use pattern matching rather than `fst` and `snd`
favonia has quit [Ping timeout: 245 seconds]
favonia has joined #ocaml
<d_bot> <Christophe> Or maybe `last`is fine but not inclusive:
<d_bot> <Christophe> ```ocaml
<d_bot> <Christophe> let start = if ... then 1 else 0 in
<d_bot> <Christophe> let last = start + a in
<d_bot> <Christophe> for i = start to last - 1 do ... done;
<d_bot> <Christophe> let start, last = last, last + b in
<d_bot> <Christophe> ...
<d_bot> <Christophe> ```
<zozozo> please avoid long code blocks, they don't render very well on irc, ^^
<d_bot> <Christophe> oh my bad, I guess using a pastebin-like service is the way to go ? 🙂
<zozozo> yup, :)
<zozozo> adrien: companion_cube: how hard do you think it would be to make a bot that automatically tells people to not use code blocks but instead use a paste service instead ?
<d_bot> <Christophe> Actually it's written in the topic on discord, but well, like always, you have to read it :/
<adrien> zozozo: already done kind-of
<d_bot> <mimoo> how can I get the directory of the file I'm executing?
<d_bot> <mimoo> I'm using Sys.argv.(0) but this doesn't work with rules
<zozozo> adrien: how so ?
<adrien> zozozo: the bot I've made on top of calculon is mostly an anti-spam bot (which is itself spammy on freenode) but its sole answer so far is to ban people
<adrien> the trouble is that it cannot stop pastes without banning and that's typically too much (unless some conditions which are too difficult to write properly into a program)
<adrien> but it could also warn
<zozozo> also, you probably do not want to ban d_bot ...
<adrien> or it needs a magic (which could be the case with d_bot but I'm not familiar with it)
<zozozo> and considering such spam usually comes from discord you'd need to extract the discord nick and hl the nick with an '@'
<zozozo> if d_bot could automatically transform long code blocks into pastes that'd be ideal
<companion_cube> I wonder if matterbridge or whatever is used, could be patched
<adrien> definitely
<companion_cube> after all the discord side knows a lot more about what's posted
<companion_cube> if there's code fences and everything
<adrien> @mimoo: it would be something like Filename.concat (Sys.getcwd ()) (Filename.dirname Sys.argv.(0))
<zozozo> would that work even if sys.argv.(0) is an absolute path (and can it be an absolute path ?) ?
<adrien> @mimoo: but the result is not completely pretty (there could be ../../x/../x/../x/../x/y)
<adrien> zozozo: right, that code definitely wouldn't work in that case
<adrien> Filename.is_relative Sys.argv.(0)
<d_bot> <mimoo> btw here's the rule I use:
<d_bot> <mimoo>
<d_bot> <mimoo> ```
<d_bot> <mimoo> (rule
<d_bot> <mimoo> (alias runtest)
<d_bot> <mimoo> (action
<d_bot> <mimoo> (run ./main.exe)))
<d_bot> <mimoo> ```
<d_bot> <mimoo> so that my code runs when I run `dune runtest`
<adrien> zozozo: the bot is also a bit spammy because of ```
<zozozo> yup
<adrien> @mimoo: looks like Sys.getcwd () should do everything you need (I don't know if dune has some better facility for that however)
<d_bot> <mimoo> ah great, it almost works except that it gives me the path within the _build directory
<d_bot> <mimoo> I guess I could copy the files I need there
<d_bot> <mimoo> using `(deps x y)` in my rule seems to work
<d_bot> <mimoo> thx!
tane has quit [Quit: Leaving]
<d_bot> <mimoo> actually, now it doesn't work if I exec it from another folder...
<d_bot> <mimoo> `getcwd` changes depending on where I execute this from o.o
<d_bot> <mimoo> not a big deal though...
<d_bot> <Christophe> you can write multiline on IRC, right? Haven't used it in some time
<adrien> @mimoo: yeah, that's exactly what getcwd is about: the current working directory
<zozozo> @mimoo : you can also take a look at that if you want a more robust solution for loading files : https://dune.readthedocs.io/en/stable/sites.html#sites
<adrien> therefore (by default) from where the progream is started from
<d_bot> <mimoo> interesting thx!
waleee has quit [Ping timeout: 245 seconds]
waleee has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
favonia has quit [Remote host closed the connection]
favonia has joined #ocaml
cedric has quit [Quit: Konversation terminated!]
shawnw has joined #ocaml
oriba has joined #ocaml
dhil has quit [Ping timeout: 252 seconds]
Haudegen has quit [Ping timeout: 252 seconds]
hackinghorn has joined #ocaml
motherfsck has quit [Ping timeout: 268 seconds]
vicfred has quit [Quit: Leaving]
motherfsck has joined #ocaml
motherfsck has quit [Ping timeout: 250 seconds]
motherfsck has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]