companion_cube changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.11 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.11/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
curtosis has joined #ocaml
curtosis is now known as curtosis[away]
mxns has quit [Ping timeout: 265 seconds]
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
hackinghorn has joined #ocaml
mxns has joined #ocaml
<dieggsy> Is the only way to test Zarith bigint equality really to do (Z.compare a b) = 0 ?
<dieggsy> i feel like there must be something easier
<sleepydog> there is Z.equal
<dieggsy> lol
<dieggsy> Guess i'll take it
<hackinghorn> I have a variable prog, what is ~prog:prog
<sleepydog> that's passing prog as the value of the labelled argument "prog"
<sleepydog> because "prog" and "prog" have the same name, you can write it as ~prog
<hackinghorn> erm, ah, ok
<hackinghorn> thanks, let me read more
<sleepydog> Look for "label punning" on that page
mxns has quit [Ping timeout: 248 seconds]
<hackinghorn> ahh thanks, I kinda see
<hackinghorn> also, what is janestreet
<hackinghorn> I can't find Unix.exec on https://ocaml.org/api
<hackinghorn> but I can find Unix.exec on janestreet
mxns has joined #ocaml
curtosis has joined #ocaml
curtosis is now known as curtosis[away]
<companion_cube> dieggsy: Z.(a = b) also works :)
<dieggsy> it doesn't, actually
<dieggsy> well, it doesn't for me... maybe something to do with open Base ?
<d_bot> <sgrove> Is anyone using ocaml/ocaml-lsp with emacs? I can't get it to recognize dependencies:
<d_bot> <sgrove> It seems like it's running (and looks very cool!), but I suspect I'm not initializing something correctly
<d_bot> <sgrove> Using ocaml-platform in vscode (`esy code`), it seems to work:
<dieggsy> companion_cube: hmm, it is to do with open Base
<companion_cube> maybe? open Base will overload a lot of things, including =
<companion_cube> also this works only on last Zarith
<companion_cube> latest
mxns has quit [Ping timeout: 240 seconds]
dckc has joined #ocaml
<dieggsy> yeah, it works without opening base
<dieggsy> I rather like base, but there's one or two things about it that are extremely annoying lol
<companion_cube> make sure you have latest zarith
<companion_cube> otherwise you'll get polymorphic equality
<sleepydog> i guess that's from Base's replacement of the polymorphic =
<companion_cube> (whic I think works on Z.t but not Q.t)
<companion_cube> yes
<sleepydog> i would have thought the more local open in Z.() would shadow the outer `open Base`
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
<companion_cube> it does
<companion_cube> if you have = in it, which requires zairth 1.6 iirc
<companion_cube> hmm oops, anyway, latest zairth
<companion_cube> it's a recent change
<sleepydog> ah ok, so it doesn't work for dieggsy because he doesn't have new zarith and it's using Base's = instead
<companion_cube> I think
<sleepydog> makes sense
<dieggsy> companion_cube: wait, i'm on zarith 1.12 ?
<dieggsy> = in Z.() is somehow /not/ shadowing the outer =
<sleepydog> it looks like '=' is in Zarith.Compare, at least in github master
<dieggsy> so wait, am i doing something wrong, or does = in fact not work in Z.() after you open Base
<dieggsy> it's also not in the docs fwiw https://antoinemine.github.io/Zarith/doc/latest/Z.html
<sleepydog> based on what's in zarith in github i think you'd have to do Z.Compare.(a = b) which is more typing than Z.equal a b
<companion_cube> ahahah so they move it _out_
<companion_cube> saf
<companion_cube> sad
<sleepydog> looks like it was moved out in 2019
<dieggsy> sleepydog: that is more writing, and also ~$ doesn't work in Z.Compare()
<sleepydog> i agree it's more writing. what is ~$ ?
<dieggsy> sleepydog: an alias for of_int
<sleepydog> oh, i see. that's in the outer Z module. heh
<dieggsy> Still though, this issue only happens when opening base
<dieggsy> so = /does/ still work in Z.() /if/ you're not using base
<sleepydog> well, without base you're getting the poly compare
<dieggsy> Ah, right.
<sleepydog> i think it's best to just live with the "ugly" Z.equal
<sleepydog> or ask about changing Zarith back
<dieggsy> i agree, i think i like what base has to offer
<dieggsy> sleepydog: do you use base or no?
<sleepydog> i don't
<dieggsy> maybe i should just try that huh
<sleepydog> if you use base extensively i think you'll probably miss it. it's much bigger than ocaml stdlib
<dieggsy> sleepydog: i've only just started using OCaml actually, i have a total of 10 short files written
<dieggsy> so maybe i can live without it
<dieggsy> i was just trying it because it was recommended various places
<dieggsy> hah, well I like % and List.range. those are nice
<sleepydog> is % modulo ?
<dieggsy> yeah
<dieggsy> they also have named parameters for things like fold/filter, so you can do ~f: and put the arguments in any intuitive order. maybe i'll stick to base after all lol
<sleepydog> i don't think you should switch from base over this zarith issue, especially since it doesn't really "fix" the issue.
<sleepydog> i like to use the stdlib because if i end up sharing my code it won't require several MB of dependencies, and i have more faith that ocaml stdlib will stay backwards compatible
<dieggsy> See, but i value those thing stoo
<dieggsy> right now i'm just re-doing some project euler problems in ocaml, so it's not like it matters
<dieggsy> it's just my brain being like "go the minimalist/portable route"
<sleepydog> heh. i have that same urge too, and i think it holds me back from getting anything done a lot of the time
<dieggsy> that's fair
mxns has joined #ocaml
mxns has quit [Ping timeout: 250 seconds]
<dieggsy> oof, standard library doesn't even have stuff like string reversal
mxns has joined #ocaml
mxns has quit [Ping timeout: 248 seconds]
<hackinghorn> I can't find Unix.exec on https://ocaml.org/api/Unix.html
<hackinghorn> but after some googling, I found it here https://ocaml.janestreet.com/ocaml-core/109.55.00/tmp/core/Unix.html
<hackinghorn> can't they just be in one place?
<hackinghorn> mm what is base, or janestreet :/
<dh`> hackinghorn: ?
<dh`> val execve : string -> string array -> string array -> 'a
<companion_cube> base is a stdlib from janestreet, which is a big financial company and the biggest industrial OCaml user
<hackinghorn> dh`, that's execv, not exec
<dh`> there is no exec system call, exec is a family of functions
<dh`> execve is the base one
<hackinghorn> I can call Unix.exec, its on the page I showed
<hackinghorn> its weird eh
mxns has joined #ocaml
<dh`> that's just a wrapper
<dh`> and not of any particular use
<hackinghorn> or are they not the same Unix
<sleepydog> hackinghorn: like companion_cube said, that is from an alternate stdlib.
<hackinghorn> wow, I see, the alternate one
<sleepydog> the built-in stdlib more closely follows the actual system calls available on a unix system, so you use execv or execve
<hackinghorn> so janestreet has a different Unix
<dh`> or execvp or execvpe
<dh`> doesn't have execl* but that's kinda pointless in ocaml
<hackinghorn> ah I see, thxx
<dh`> (execvp, execvpe, and execv are libc-level wrappers around the execve system call)
mxns has quit [Ping timeout: 248 seconds]
<hackinghorn> can I use both stdlib at the same time?
<hackinghorn> how do I know which one I'm using?
<hackinghorn> I can go to definition but what after that?
zebrag has quit [Quit: Konversation terminated!]
mxns has joined #ocaml
mxns has quit [Ping timeout: 248 seconds]
White_Flame has quit [Ping timeout: 240 seconds]
mxns has joined #ocaml
White_Flame has joined #ocaml
waleee-cl has quit [Quit: Connection closed for inactivity]
<hackinghorn> hi anyone?
mxns has quit [Ping timeout: 240 seconds]
White_Flame has quit [Ping timeout: 260 seconds]
mfp has quit [Ping timeout: 260 seconds]
<sleepydog> hackinghorn: it's better to use one or the other
<sleepydog> if you have `open Base` at the top of your ocaml file, you're using Base. otherwise you're using the built-in stdlib
<sleepydog> you should just go with whatever is used in the learning material you're using
<hackinghorn> ahh, I see
<hackinghorn> so if I see 'open Base' I should stick with Base, if I dont see it, I stick with built-in stdlib
<hackinghorn> I guess I can use both but shouldn't
<sleepydog> it's a pain to use both
<sleepydog> but i think Base makes the ocaml stdlib available under a different name if you need it
<hackinghorn> I see "open Core", Core is Base' extension?
<hackinghorn> ah thats right
tryte has quit [Remote host closed the connection]
tryte has joined #ocaml
<hackinghorn> eh, how do I fix this code: open Core print_endline "Hello"
<hackinghorn> open Core;; I think
curtosis[away] has joined #ocaml
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
Deek9399 has joined #ocaml
mbuf has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 246 seconds]
narimiran has joined #ocaml
Serpent7776 has joined #ocaml
Sonakshi has joined #ocaml
Sonakshi has quit [Quit: Connection closed]
Deek9399 has quit [Quit: Connection closed]
neiluj has joined #ocaml
mxns has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
neiluj has quit [Remote host closed the connection]
olle_ has joined #ocaml
olle_ has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
bronsen has quit [*.net *.split]
|jbrown| has quit [*.net *.split]
dwt has quit [*.net *.split]
nullcone has quit [*.net *.split]
thizanne has quit [*.net *.split]
raver has quit [*.net *.split]
webshinra has quit [*.net *.split]
SrPx has quit [*.net *.split]
terabit has quit [*.net *.split]
cemerick has quit [*.net *.split]
b20n has quit [*.net *.split]
takside has quit [*.net *.split]
lisq has quit [*.net *.split]
cbarrett has quit [*.net *.split]
theglass has quit [*.net *.split]
caasih has quit [*.net *.split]
RalfJ has quit [*.net *.split]
_ks has quit [*.net *.split]
Enjolras has quit [*.net *.split]
mosterdt__ has quit [*.net *.split]
Ekho has quit [*.net *.split]
infinigon_ has quit [*.net *.split]
radiopotin[m] has quit [*.net *.split]
averell has quit [*.net *.split]
nfc has quit [*.net *.split]
_habnabit has quit [*.net *.split]
tmhoang520 has quit [*.net *.split]
Johann has quit [*.net *.split]
OPeritel_ has quit [*.net *.split]
drakonis has quit [*.net *.split]
Putonlalla has quit [*.net *.split]
dinosaure has quit [*.net *.split]
SoF has quit [*.net *.split]
stylewarning has quit [*.net *.split]
gahr has quit [*.net *.split]
eternalgeek[m] has quit [*.net *.split]
lnxw37d4 has quit [*.net *.split]
tryte has quit [*.net *.split]
cantstanya has quit [*.net *.split]
andreas303 has quit [*.net *.split]
nicoo has quit [*.net *.split]
aditi314 has quit [*.net *.split]
BitPuffin has quit [*.net *.split]
penguwin has quit [*.net *.split]
bacam has quit [*.net *.split]
Drup has quit [*.net *.split]
rfv has quit [*.net *.split]
artart78 has quit [*.net *.split]
smondet[m] has quit [*.net *.split]
pqwy[m] has quit [*.net *.split]
peddie has quit [*.net *.split]
Sumera[m] has quit [*.net *.split]
tristanC has quit [*.net *.split]
conjunctive has quit [*.net *.split]
Leonidas has quit [*.net *.split]
adrianbrink has quit [*.net *.split]
wagle has quit [*.net *.split]
vodkaInf1rno has quit [*.net *.split]
delysin has quit [*.net *.split]
dmbaturin has quit [*.net *.split]
incoh has quit [*.net *.split]
kini has quit [*.net *.split]
Duns_Scrotus has quit [*.net *.split]
mrallen1 has quit [*.net *.split]
jimt[m] has quit [*.net *.split]
ocabot has quit [*.net *.split]
reynir has quit [*.net *.split]
sar has quit [*.net *.split]
cqc has quit [*.net *.split]
zozozo has quit [*.net *.split]
beaky has quit [*.net *.split]
stux|RC-only has quit [*.net *.split]
dieggsy has quit [*.net *.split]
bytesighs has quit [*.net *.split]
stephe has quit [*.net *.split]
angerman has quit [*.net *.split]
wildsebastian has quit [*.net *.split]
robmyers has quit [*.net *.split]
adi__________ has quit [*.net *.split]
pmonson has quit [*.net *.split]
ipavlo has quit [*.net *.split]
copy_ has quit [*.net *.split]
oznt has quit [*.net *.split]
ski has quit [*.net *.split]
osa1 has quit [*.net *.split]
rak has quit [*.net *.split]
troydm has quit [*.net *.split]
companion_cube has quit [*.net *.split]
Chouhartem has quit [*.net *.split]
ahf has quit [*.net *.split]
Ankhers has quit [*.net *.split]
infinity0 has quit [*.net *.split]
p4bl0 has quit [*.net *.split]
ebb has quit [*.net *.split]
l1x has quit [*.net *.split]
higherorder__ has quit [*.net *.split]
JSharp has quit [*.net *.split]
omni has quit [*.net *.split]
mgsk has quit [*.net *.split]
d_bot has quit [*.net *.split]
Fardale has quit [*.net *.split]
CcxWrk has quit [*.net *.split]
rom1504 has quit [*.net *.split]
lopex has quit [*.net *.split]
ec has quit [*.net *.split]
Geekingfrog has quit [*.net *.split]
leah2 has quit [*.net *.split]
metadave has quit [*.net *.split]
vicfred has quit [*.net *.split]
rpcope has quit [*.net *.split]
daimrod has quit [*.net *.split]
adrien has quit [*.net *.split]
jmct has quit [*.net *.split]
pippijn has quit [*.net *.split]
brettgilio has quit [*.net *.split]
narimiran has quit [*.net *.split]
hackinghorn has quit [*.net *.split]
olle has quit [*.net *.split]
TC01 has quit [*.net *.split]
aquijoule_ has quit [*.net *.split]
xandkar has quit [*.net *.split]
freshmaker666 has quit [*.net *.split]
schlaftier has quit [*.net *.split]
rwmjones has quit [*.net *.split]
mbuf has quit [*.net *.split]
dh` has quit [*.net *.split]
tizoc has quit [*.net *.split]
iZsh has quit [*.net *.split]
hannes has quit [*.net *.split]
sleepydog has quit [*.net *.split]
runawayfive has quit [*.net *.split]
beajeanm has quit [*.net *.split]
terrorjack has quit [*.net *.split]
valtr has quit [*.net *.split]
interruptinuse has quit [*.net *.split]
dx has quit [*.net *.split]
clockish has quit [*.net *.split]
ansiwen_ has quit [*.net *.split]
johnelse has quit [*.net *.split]
dan64- has quit [*.net *.split]
jca has quit [*.net *.split]
mrd has quit [*.net *.split]
nore has quit [*.net *.split]
sim642 has quit [*.net *.split]
eagleflo has quit [*.net *.split]
remexre has quit [*.net *.split]
lobo has quit [*.net *.split]
asm89 has quit [*.net *.split]
seliopou has quit [*.net *.split]
rntz2 has quit [*.net *.split]
theblatte has quit [*.net *.split]
srax has quit [*.net *.split]
jsoo has quit [*.net *.split]
madroach has quit [*.net *.split]
octachron has quit [*.net *.split]
xenu has quit [*.net *.split]
zmagii has quit [*.net *.split]
_tjr_ has quit [*.net *.split]
haskell_1 has quit [*.net *.split]
Exagone313 has quit [*.net *.split]
drewolson has quit [*.net *.split]
rks` has quit [*.net *.split]
avsm[m] has quit [*.net *.split]
dash has quit [*.net *.split]
flux has quit [*.net *.split]
breitenj has quit [*.net *.split]
runciter has quit [*.net *.split]
chewbranca has quit [*.net *.split]
madgen_ has quit [*.net *.split]
jeroud has quit [*.net *.split]
Armael has quit [*.net *.split]
cross has quit [*.net *.split]
Nahra has quit [*.net *.split]
Serpent7776 has quit [*.net *.split]
landonf has quit [*.net *.split]
chripell_ has quit [*.net *.split]
shmibs has quit [*.net *.split]
mal`` has quit [*.net *.split]
stux|RC has quit [*.net *.split]
so_ has quit [*.net *.split]
engil has quit [*.net *.split]
Haudegen has quit [*.net *.split]
dckc has quit [*.net *.split]
Amaan has quit [*.net *.split]
alexey has quit [*.net *.split]
SquidDev has quit [*.net *.split]
haesbaert has quit [*.net *.split]
emias has quit [*.net *.split]
arecaceae has quit [*.net *.split]
tjammer[m] has quit [*.net *.split]
qwr has quit [*.net *.split]
sadiq has quit [*.net *.split]
greenbagels has quit [*.net *.split]
steenuil has quit [*.net *.split]
labor[m] has quit [Ping timeout: 276 seconds]
aspiwack[m] has quit [Ping timeout: 276 seconds]
ec has joined #ocaml
ebb has joined #ocaml
ec has quit [Ping timeout: 250 seconds]
tryte has joined #ocaml
cantstanya has joined #ocaml
andreas303 has joined #ocaml
nicoo has joined #ocaml
stephe has joined #ocaml
chewbranca has joined #ocaml
wildsebastian has joined #ocaml
JSharp has joined #ocaml
stylewarning has joined #ocaml
ahf has joined #ocaml
angerman has joined #ocaml
conjunctive has joined #ocaml
cbarrett has joined #ocaml
higherorder__ has joined #ocaml
ec has joined #ocaml
SrPx has joined #ocaml
rfv has joined #ocaml
nullcone has joined #ocaml
andreas303 has quit [Ping timeout: 240 seconds]
andreas303 has joined #ocaml
bartholin has joined #ocaml
adrianbrink has joined #ocaml
wildsebastian has joined #ocaml
stephe has joined #ocaml
stephe has quit [Changing host]
wildsebastian has quit [Changing host]
stylewarning has joined #ocaml
conjunctive has joined #ocaml
higherorder__ has joined #ocaml
ec has joined #ocaml
SrPx has joined #ocaml
angerman has joined #ocaml
nullcone has joined #ocaml
rfv has joined #ocaml
angerman has quit [Changing host]
stylewarning has quit [Changing host]
conjunctive has quit [Changing host]
higherorder__ has quit [Changing host]
ec has quit [Changing host]
SrPx has quit [Changing host]
nullcone has quit [Changing host]
rfv has quit [Changing host]
mxns has joined #ocaml
mxns has quit [Ping timeout: 245 seconds]
olle has joined #ocaml
BitPuffin has joined #ocaml
Exagone313 has joined #ocaml
madroach has joined #ocaml
jsoo has joined #ocaml
5EXAABHZ9 has joined #ocaml
_tjr_ has joined #ocaml
zmagii has joined #ocaml
octachron has joined #ocaml
xenu has joined #ocaml
rks` has joined #ocaml
drewolson has joined #ocaml
haskell_1 has joined #ocaml
<hackinghorn> hi, what does ~ mean in functions?
<olle> Named argument? Or negation?
<olle> Context
Sumera[m] has joined #ocaml
dieggsy has joined #ocaml
radiopotin[m] has joined #ocaml
aspiwack[m] has joined #ocaml
dash has joined #ocaml
labor[m] has joined #ocaml
peddie has joined #ocaml
flux has joined #ocaml
jimt[m] has joined #ocaml
avsm[m] has joined #ocaml
pqwy[m] has joined #ocaml
aditi314 has joined #ocaml
smondet[m] has joined #ocaml
lnxw37d4 has joined #ocaml
eternalgeek[m] has joined #ocaml
tjammer[m] has joined #ocaml
<hackinghorn> olle, thanks, on the description of String.split:
<hackinghorn> val split : t -> on:char -> t list
<hackinghorn> split s ~on returns a list of substrings of s that are separated by on. Consecutive on characters will cause multiple empty strings in the result. Splitting the empty string returns a list of the empty string, not the empty list.
<hackinghorn> can you give an example of String.split
<hackinghorn> I tried it first time but looks like I got syntax error
tane has joined #ocaml
<olle> I actually can't
<olle> But anyone else can
<olle> If they're awake :)
<thizanne> String.split ~on:',' "a,b,c"
<olle> There ya go
<hackinghorn> ah thankss
<hackinghorn> thizanne, the ~on: is mandatory?, I tried, String.split "a,b,c" ',' and it doesnt work
<hackinghorn> thanks, I will try this way
<thizanne> hackinghorn: yes, that's a named argument
<thizanne> (for completeness, sometimes you can omit the name, but just consider you can't)
<thizanne> hackinghorn: https://dev.realworldocaml.org/variables-and-functions.html look for "Labeled arguments"
<hackinghorn> ahh thankss
<hackinghorn> I understand that Ocaml don't like loops
<hackinghorn> how to loop thru a list the Ocaml way?
<d_bot> <EduardoRFS> List.iter?
<Armael> or write a recursive function
<thizanne> ^
<d_bot> <EduardoRFS> yeah, but lists are recursive normally, it's terrible everytime I see someone doing linked lists with loops
<hackinghorn> ah, I will try List.iter, thankss
<olle> map, fold, iter
<hackinghorn> I want to loop thru a List, but if condition x is satisfied, I stop the loop. How to do that?
<hackinghorn> x is satisfied for element a of the list
<Armael> write a recursive function
<hackinghorn> ah I see, thats probably it
<d_bot> <EduardoRFS> or List.find
<hackinghorn> hehehe thanks
<olle> filter
Serpent7776 has joined #ocaml
<olle> and find_opt, I guess
<olle> instead of find
<hackinghorn> ahh great, thankss
<hackinghorn> find returns an 'a option and find_exn returns an 'a. What does exn stand for? I see it a lot
<steenuil> exn stands for exception
<hackinghorn> ah, thankss
<steenuil> can two different variants in the same module have the same name? e.g. `type a = A | B;; type b = A | C`?
<octachron> Yes, but using the first one will require type-directed disambiguation
<steenuil> hmm I see
<olle> new feature, I think? to allow this?
<olle> that always was a problem with record fields before
<olle> They changed it to find_exn? So there's both _opt and _exn in the standard lib now? oO
<octachron> If new means "less than seven years old". This was added in 4.01.0.
<olle> :)
<olle> I did most of my OCaml programming 3.12
mfp has joined #ocaml
<steenuil> huh I thought there would be a find_index function in the List module but there's none
<olle> nth
<steenuil> that's indexing a list
<steenuil> find_index would be ('a -> bool) -> 'a list -> int
<steenuil> or int option
<olle> ?
<octachron> find_index is kind of useless? since you will still need to traverse the list to use the index.
<octachron> Thinking of indices is a good sign that we should be using arrays and not lists.
<steenuil> I guess
<steenuil> I have to remove duplicates from a list, I didn't really want to use fold_left but I guess I'll have to
<steenuil> has there ever been discussion for adding a uniq function to List?
<octachron> Removing non-consecutive duplicates from a list should be done by transforming the list into a set.
<steenuil> maybe I want to preserve the order
<octachron> Decorate the list with the initial order, and then convert to a set.
<steenuil> I can see that but I find that a bit too laborious for something as simple as removing duplicates
<octachron> Or you can fold_left with a set. Overall, it is a two or three line function.
<hackinghorn> how can I get a substring starting at 5th character?
<hackinghorn> I'm using Base
<hackinghorn> looks like Base doesnt have String.sub?
<steenuil> yeah, but still, it's a two or three line function that I'll have to rewrite every time I need to use it
<hackinghorn> oh it does, silly me lol
<thizanne> steenuil: that really looks like you shouldn't be using lists in the first place though
<thizanne> what are you actually trying to do?
zebrag has joined #ocaml
<steenuil> it's an AST, there's a million other ways I could do this but this is the quickest :P
<steenuil> basically there's a pass where I add some nodes in certain situations and I noticed I ended up with duplicate nodes
<steenuil> nodes = declarations
<thizanne> well you could start with not adding a node if it's already there (if List.mem ...)
<steenuil> yeah, like I said, there's a million other ways I could do it
<hackinghorn> wait, I can't find String.sub in Base
<hackinghorn> only in stdlib
<hackinghorn> I have to use String.sub from stdlib?
<hackinghorn> wait, Base does have String.sub
<hackinghorn> but I don't see it in the doc
mxns has joined #ocaml
mxns has quit [Ping timeout: 250 seconds]
gareppa has joined #ocaml
mxns has joined #ocaml
gareppa has quit [Remote host closed the connection]
Fardale has joined #ocaml
mxns has quit [Ping timeout: 258 seconds]
waleee-cl has joined #ocaml
<d_bot> <fangyi> It's written in an non-obvious way
<d_bot> <fangyi> "val sub : (t, t) Blit.sub"
<d_bot> <fangyi> where "type nonrec ('src, 'dst) sub = ('src, 'dst) Base__.Blit_intf.sub" and "type ('src, 'dst) sub = 'src -> pos:int -> len:int -> 'dst"
mxns has joined #ocaml
mxns has quit [Ping timeout: 240 seconds]
5EXAABHZ9 has quit [Quit: Aloha!]
stux|RC has joined #ocaml
Goodiec has joined #ocaml
narimiran has joined #ocaml
SDAChess has joined #ocaml
SDAChess has left #ocaml [#ocaml]
zebrag has quit [Quit: Konversation terminated!]
Haudegen has joined #ocaml
zebrag has joined #ocaml
cantstanya has quit [Remote host closed the connection]
mxns has joined #ocaml
Sakshi has joined #ocaml
Sakshi has quit [Client Quit]
Goodiec has quit [Ping timeout: 240 seconds]
olle has quit [Ping timeout: 245 seconds]
mariaikoro has joined #ocaml
<d_bot> <EduardoRFS> There was any discussion about switching the OCaml CLI to cmdliner? Or something a bit more fancy?
<d_bot> <Drup> This means integrating cmdliner inside the compiler
<d_bot> <Drup> and that is seen as rather ... non desirable, for gains that are not very big, especially since nowadays, nobody compilers ocaml by hand
waleee-cl has quit [Quit: Connection closed for inactivity]
<d_bot> <Drup> the more objective look on this is: "Whatever the feature provided by cmdliner, if it's considered so desirable that we want it in the compiler, we can certainly finds way to add it with `Args`"
<d_bot> <Drup> (unfortunately, that doesn't completely hold for "sane CLI definition in the code", but that's another story)
<companion_cube> Arg isn't that bad -_-
<d_bot> <Drup> companion_cube: it isn't, but Args doesn't allo you to easily 1) define self-contained subterms 2) reuse subterms in different CLIs
<companion_cube> no, but for ocamlc it's probably fine?
<d_bot> <Drup> which is something that would simplify the driver's code immensely.
<companion_cube> fwiw cmdliner has this weird limitation that it can't nest further than 2
<companion_cube> which… 🤷
<d_bot> <Drup> can't nest subcommands, but we don't care about that
<d_bot> <Drup> I'm talking about "terms" as in "bunches of arguments", not subcommands
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
<companion_cube> ah well, you can reuse list of options, as long as the stuff they change is shared
<d_bot> <Drup> yeah, and the result is mutable stuff flying everywhere
<d_bot> <Drup> everyone who has touched the compiler driver will tell you how painful the result is
<companion_cube> I mean, I don't disagree
<companion_cube> cmdliner just doesn't strike me as being particularly simpler, especially when you need to make functions with 50 arguments to fit into the applicative framework
<d_bot> <Drup> The main difference for me is that you can abstract/encapsulate several arguments into a term
<companion_cube> at this point, maybe a lightweight applicative parser could be added to the compiler?
<companion_cube> ("how hard can it be", lolol)
<d_bot> <Drup> I don't know. I think everyone just gave up of every cleaning this part of the code until it gain sentience and decide to turn on its creators
<companion_cube> tbh I wish we had more stuff in .ml files, and less on the command line
<companion_cube> (like, dependencies, flags, etc.)
Goodiec has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
mxns has quit [Ping timeout: 252 seconds]
<d_bot> <EduardoRFS> nobody, except people developing tools who wants sane args. But yeah the idea is not necessarily cmdliner.
<d_bot> <EduardoRFS>
<d_bot> <EduardoRFS> Would be cool if there was a way to bail out of cmdliner like with menhir
waleee-cl has joined #ocaml
<companion_cube> wouldn't it be cool if you could just give ocaml a json object on stdin to specify the arguments? :p
<companion_cube> for tool writers it's probably simpler this way
Tuplanolla has joined #ocaml
bartholin has quit [Quit: Leaving]
SquidDev has joined #ocaml
mxns has joined #ocaml
SquidDev has quit [Client Quit]
SquidDev has joined #ocaml
Goodiec has quit [Quit: Connection closed]
<d_bot> <Drup> Honestly, even then, you don't really need it: Any such tool will probably not be user-facing either, but only used through .. a build system. And in that case, your best bet is to preserve the compiler's CLI as much as possible
SquidDev has quit [Quit: Bye!]
SquidDev has joined #ocaml
TheLemonMan has joined #ocaml
mariaikoro has left #ocaml [#ocaml]
Haudegen has joined #ocaml
ArthurStrong has joined #ocaml
<zozozo> i confirm that adding an option to the compiler is... annoying at least, :p
<zozozo> we have a lof of that with flambda, XD
<companion_cube> I recommend Sys.getenv_opt :)
<companion_cube> 👿
<zozozo> we have that too
<zozozo> ...
<companion_cube> tbh for any flag that is in `flambda \ ocamlopt` it kind of makes sense… bypass the build system :)
<companion_cube> (for debug stuff, ofc; for the rest I hope regular ocamlopt will accept the same options and just ignore them)
olle_ has joined #ocaml
<d_bot> <rgrinberg> @EduardoRFS don't waste time on improving the driver, what we really need is a "server" mode for the compiler
<d_bot> <EduardoRFS> agreed, but it's because of a friend of mine wasted his time on `bsc` for Melange, then I was thinking "we could maybe use this for OCaml"
<d_bot> <rgrinberg> I mean, if there's a use case for running `bsc` manually then it makes sense
<d_bot> <rgrinberg> but it never makes sense for the OCaml compiler
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
vicfred has joined #ocaml
olle_ has quit [Ping timeout: 240 seconds]
<d_bot> <Robin> hello i don't know where to ask so i'm putting that here:
<d_bot> <Robin> let melange_knuth t=
<d_bot> <Robin> for i=0 to (Array.length (t)-1)
<d_bot> <Robin> do let j = random.int(k+1)
<d_bot> <Robin> in let att=t.(j);
<d_bot> <Robin> t.(j)<-t.(i);
<d_bot> <Robin> t.(i)<-att
<d_bot> <Robin> done;
<d_bot> <Robin> t;;
<d_bot> <Robin> i don't know where there is a mistake in the syntaxe
<d_bot> <Robin> can someone help me?
<d_bot> <octachron> The binding syntax is `let ... = ... in` not `let ... ;`.
mxns has quit [Ping timeout: 250 seconds]
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
mxns has joined #ocaml
mxns has quit [Ping timeout: 258 seconds]
ArthurStrong has quit [Quit: leaving]
mxns has joined #ocaml
mxns has quit [Ping timeout: 260 seconds]
<notnotdan_> rgrinberg, what do you mean by a 'sever' mode for the compiler?
<companion_cube> I guess, the compiler would run as a daemon and accept compilation commands on some socket
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
<steenuil> at that point wouldn't it be better to have the compiler be usable as a library?
oriba has joined #ocaml
curtosis has joined #ocaml
<companion_cube> it's already usable as a library
narimiran has quit [Ping timeout: 260 seconds]
<steenuil> oh.
<companion_cube> however I'm not sure if the API is stable.
mxns has joined #ocaml
<d_bot> <rgrinberg> Using it as a library would force us to link it to the build sytem
<d_bot> <rgrinberg> That would be prohibitive
<companion_cube> dune is doing RPC with more and more things, rgrinberg, correct?
<d_bot> <rgrinberg> Whenever we need loose coupling it makes sense to go with RPC
<d_bot> <rgrinberg> But we only recently gained a usable RPC mechanism
<d_bot> <rgrinberg> so we're still trying to adopt it where possible
<steenuil> what's a good way to represent a bitmask?
<companion_cube> steenuil: an int, with bitwise operations :)
<companion_cube> rgrinberg: right. Based on csexp, correct?
<d_bot> <rgrinberg> Yeah
<d_bot> <rgrinberg> Quit similar to jsonrpc actually. But with csexp instead of json
<steenuil> eh. I was thinking either a list of enums or something with a functor and some infix operator to compose them
<steenuil> list of enums sounds like the most lightweight
<companion_cube> yeah csexp >> json
<d_bot> <rgrinberg> How is that more lightweight than a single 64 bit integer?
<companion_cube> I mean, hello binary-safe encoding
<d_bot> <rgrinberg> 63*
<steenuil> I mean in a type-safe manner, rgrinberg
<d_bot> <rgrinberg> The thing is, you might as well just use a set if you're going to have such an inefficient representation
<steenuil> obviously an int would be better, but there's a lot of bitmasks in the API
<steenuil> true
curtosis is now known as curtosis[away]
<d_bot> <rgrinberg> companion_cube how come you didn't make that work for any number of elements?
mxns has quit [Ping timeout: 250 seconds]
mxns has joined #ocaml
<companion_cube> hmm why would i? :p
<companion_cube> that requires an array
<companion_cube> (or `bytes`)
<steenuil> that looks nice, companion_cube
<d_bot> <rgrinberg> bytes would be the way to go
<companion_cube> but if you have only a few fields, using an int is much more lightweight
<companion_cube> so it's just a different thing
<companion_cube> although it uses a `int array`, not bytes…
<companion_cube> hmm
<companion_cube> maybe I should refactor to use bytes
<d_bot> <rgrinberg> It's a shame that something like this can't be unboxed: `type t = Small of int | Big of Bytes.t`
<companion_cube> not without the Zarith trick, yeah
<companion_cube> I mean. you can, if you want to use Obj
<companion_cube> (since integers and blocks can be distinguished at runtime)
<d_bot> <rgrinberg> yaeh, it can be done in this case for sure
mxns has quit [Quit: ZNC 1.8.2 - https://znc.in]
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
mxns has joined #ocaml
<companion_cube> it would work… but I'd rather not rely that heavily on Obj ^^
<companion_cube> (there's already a bit of it in CCVector and I'm not fond of it)
zebrag has quit [Read error: Connection reset by peer]
zebrag has joined #ocaml
mxns has quit [Ping timeout: 265 seconds]
mxns has joined #ocaml
Serpent7776 has quit [Quit: leaving]
mxns has quit [Ping timeout: 250 seconds]
mxns has joined #ocaml
White_Flame has joined #ocaml
reffter has joined #ocaml
reffter has left #ocaml [#ocaml]
mxns has quit [Quit: ZNC 1.8.2 - https://znc.in]
mxns has joined #ocaml
<d_bot> <EduardoRFS> I wonder if the compiler team would accept this
<d_bot> <rgrinberg> Don’t they have a proposal for unboxing already? I’d imagine they’d want to finish it before considering more adhoc rules
<d_bot> <EduardoRFS> I think the proposal is for a new kind of bottom type altogether, that can unboxed, for values this wills till be desirable
mxns has quit [Ping timeout: 265 seconds]
mxns has joined #ocaml
mxns has quit [Ping timeout: 252 seconds]
curtosis has joined #ocaml
curtosis is now known as curtosis[away]
mxns has joined #ocaml
mxns has quit [Ping timeout: 240 seconds]
mxns has joined #ocaml
<d_bot> <Zach5050> Hi does anyone know how i would go about a set difference in this case
<d_bot> <Zach5050> I need to recurse down on the expression and only get the free variables that are not x
<d_bot> <colin> `SS.remove`
<d_bot> <colin> since you're doing set difference of a singleton set, you can just use `remove`
<d_bot> <colin> there's a `diff` function as well for computing `x \ y`
<d_bot> <Zach5050> i see thank you, I am not sure if my professor is allowing us to use libraries tho i have to ask
<d_bot> <Zach5050> Is that the only way to go about it?
<d_bot> <colin> you'll likely be using `Set`
<d_bot> <colin> I can't see why they wouldn't let you
<d_bot> <Zach5050> I remember him saying a while back we must only use our own functionallity
<d_bot> <colin> I feel bad posting inline code in this channel but the idea is basically `module SS = Set.Make(String)`, `let rec fvs : expr -> SS.t`
<d_bot> <colin> well you can write your own naive set implementation
<d_bot> <Zach5050> thank you! @colin
curtosis[away] has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
mxns has quit [Ping timeout: 260 seconds]
mxns has joined #ocaml
<d_bot> <Zach5050> so the fv function returns a list
<d_bot> <Zach5050> i am trying to mimic what he is doing here, does list come with functions that automatically remove values?
<d_bot> <Zach5050> Or is set the only way you can think of doing it?
<d_bot> <Zach5050> I have to return a list of free variables
mxns has quit [Ping timeout: 268 seconds]
<d_bot> <Zach5050> okay my professor has clarified that i can use open libraries such as open list, open string but no batteries
<d_bot> <colin> just use `Set`
<d_bot> <colin> honestly just ask if you can use `Set`
<d_bot> <colin> seems your final comment implies you can use `Set`
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml
tane has quit [Quit: Leaving]
<d_bot> <rw> The standard library has a nice searchable docs page: https://ocaml.org/api/
zebrag has quit [Quit: Konversation terminated!]
zebrag has joined #ocaml