spew has quit [Quit: Connection closed for inactivity]
serge_ has joined #ocaml
smazga has joined #ocaml
serge_ has quit [Ping timeout: 260 seconds]
smazga has quit [Ping timeout: 240 seconds]
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
ygrek__ has quit [Remote host closed the connection]
ygrek__ has joined #ocaml
ygrek__ has quit [Ping timeout: 260 seconds]
malina has quit [Remote host closed the connection]
Haudegen has quit [Quit: Bin weg.]
olle has quit [Ping timeout: 272 seconds]
olle has joined #ocaml
serge_ has joined #ocaml
serge_ has quit [Ping timeout: 260 seconds]
ygrek__ has joined #ocaml
serge_ has joined #ocaml
ygrek__ has quit [Ping timeout: 240 seconds]
serge_ has quit [Ping timeout: 260 seconds]
nullifidian_ has joined #ocaml
nullifidian__ has quit [Ping timeout: 265 seconds]
smazga has joined #ocaml
smazga has quit [Ping timeout: 265 seconds]
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
nullifidian has joined #ocaml
nullifidian_ has quit [Ping timeout: 265 seconds]
mfp has quit [Ping timeout: 272 seconds]
Nikkel has quit [Ping timeout: 272 seconds]
Nikkel has joined #ocaml
Haudegen has joined #ocaml
serge has joined #ocaml
tormen_ has joined #ocaml
TakinOver has joined #ocaml
lnxw37d4 has joined #ocaml
tormen has quit [Ping timeout: 260 seconds]
serge has quit [Ping timeout: 268 seconds]
mbuf has joined #ocaml
<nicolaus>
GOod day, I am using () to indicate this should be ran first, but other functions above it are ran first
<nicolaus>
I am using () to indicate that it's my sort of "main" function
<nicolaus>
Ok, got it
<nicolaus>
I just added () to all functions that has names and may "main" function only has ()
<nicolaus>
I don't understand it though
dash has joined #ocaml
<dash>
nicolaus: since we didn't see your code, neither do we
_whitelogger has joined #ocaml
smazga has joined #ocaml
ggole has joined #ocaml
smazga has quit [Ping timeout: 240 seconds]
pierpal has joined #ocaml
dash has quit [Ping timeout: 240 seconds]
gravicappa has joined #ocaml
nullifidian has quit [Read error: Connection reset by peer]
nullifidian_ has joined #ocaml
serge has joined #ocaml
serge has quit [Ping timeout: 260 seconds]
narimiran has joined #ocaml
vicfred has quit [Remote host closed the connection]
vicfred has joined #ocaml
mbuf has quit [Ping timeout: 265 seconds]
mbuf has joined #ocaml
kleisli has quit [Ping timeout: 265 seconds]
smazga has joined #ocaml
smazga has quit [Ping timeout: 268 seconds]
<Leonidas>
nicolaus: I think you're ascribing a meaning to () that just isn't there.
<Leonidas>
nicolaus: your functions execute in the order you call them in your module
<Leonidas>
if you call the functions before your main function then this is when they will execute
serge has joined #ocaml
serge has quit [Ping timeout: 240 seconds]
dborisog has joined #ocaml
LanceMarsh has joined #ocaml
Serpent7776 has joined #ocaml
<LanceMarsh>
hi, ocaml masters: why does `One h::t` matches `type 'a node = One of 'a | Many of 'a node list;;` where 'a is string? first day learning ocaml, trying to solve the 7th problem of 99 problems(https://ocaml.org/learn/tutorials/99problems.html).
<vsiles>
LanceMarsh: if you look at the type of your flatten function, you'll see that ocaml infers it to be
<vsiles>
val flatten : 'a node list -> 'a list
<vsiles>
there's no mention of strings anywhere, because you always manipulate the nodes without testing the actual data stored in it
<vsiles>
so `One h::t` doesn not match a string node
<vsiles>
it match a 'a node list
<vsiles>
Usually functions like 'flatten' take some list of lists to a simple list. Here the goad is to to take a list of nodes (which can be seen as a list of list) and produce a plain list
<vsiles>
not sure why you mention string
<LanceMarsh>
testcase is flatten [ One "a" ; Many [ One "b" ; Many [ One "c" ; One "d" ] ; One "e" ] ];;
<LanceMarsh>
i thought the pattern was to match somethign like `One "a"`
Nikkel has joined #ocaml
<vsiles>
So split up the type involved. In your test case, the argument is [ One "a"; .... ] which is a list (because of the surrounding [])
<vsiles>
In this list, you have One "a", Many [ ... ] and One "e" which are all string node
<vsiles>
so the overall type is string node list, which matches with your function types: 'a node list -> 'a is substituted with string
<vsiles>
oh I see now your issue
<vsiles>
sorry, was multitasking
<vsiles>
in your reference code
<vsiles>
One h :: t has to be read (One h) :: t
<vsiles>
it's a nested pattern matching rule which triggers if the input is a list which heads is a `One _`
<LanceMarsh>
Ah, that ^ explains everything! Thank you very much
<vsiles>
it is _not_ One (h :: t)
<Leonidas>
the precedence of :: is a bit surprising sometimes
mahtob has joined #ocaml
mahtob has quit [Read error: Connection reset by peer]
mahmudov has quit [Ping timeout: 272 seconds]
Cypi_ is now known as Cypi
lnxw37d4 has quit [Quit: killed]
bglm[m] has quit [Quit: killed]
ziyourenxiang has quit [Ping timeout: 268 seconds]
serge has joined #ocaml
ziyourenxiang has joined #ocaml
serge has quit [Ping timeout: 260 seconds]
ollehar_ has joined #ocaml
mbuf has quit [Quit: Leaving]
mahmudov has joined #ocaml
dborisog has quit [Ping timeout: 260 seconds]
aecepoglu[m] has joined #ocaml
aspiwack[m] has joined #ocaml
bglm[m] has joined #ocaml
cgenie[m] has joined #ocaml
flux has joined #ocaml
dl3br[m] has joined #ocaml
jimt[m] has joined #ocaml
keep-learning[m] has joined #ocaml
lnxw37d4 has joined #ocaml
pablo[m] has joined #ocaml
dash has joined #ocaml
peddie has joined #ocaml
prsafont[m] has joined #ocaml
zapashcanon[m] has joined #ocaml
zwindl[m] has joined #ocaml
karan has joined #ocaml
tiksin[m] has joined #ocaml
sepp2k has joined #ocaml
LanceMarsh has quit [Quit: WeeChat 2.7]
mfp has joined #ocaml
<gahr>
is there a way to build a string from the contents of a file at compile time?
<Leonidas>
gahr: yes, there is ppx_blob
<Leonidas>
lobsters is the one page on the internet where there's more ocaml-fans than haskell and in systemd discussions you see all the names from here :)
ocaml459 has joined #ocaml
<gahr>
thanks Leonidas - do you also happen to know whether incr_dom supports ajax requests somehow?
<Leonidas>
gahr: I don't use incr_dom so maybe there's a reason why that's not possible, but since you're probably using jsoo you can just do xmlhttprequest yourself?
<gahr>
yes i just don't know how to integrate that with incr_dom view / apply_action / update model cycle
<Leonidas>
Ah I see, sorry, I don't have a solution for this at hand.
pierpal has quit [Read error: Connection reset by peer]
Serpent7776 has quit [Remote host closed the connection]
Serpent7776 has joined #ocaml
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
FreeBirdLjj has quit [Remote host closed the connection]
pierpal has joined #ocaml
Haudegen has joined #ocaml
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
pierpal has quit [Ping timeout: 260 seconds]
serge has joined #ocaml
serge has quit [Ping timeout: 260 seconds]
mahtob has joined #ocaml
brettgilio has quit [Ping timeout: 240 seconds]
mahtob has quit [Remote host closed the connection]
mahmudov has quit [Ping timeout: 260 seconds]
brettgilio has joined #ocaml
mahmudov has joined #ocaml
RalfJ has quit [Ping timeout: 272 seconds]
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
dhil has quit [Ping timeout: 248 seconds]
decentpenguin has joined #ocaml
serge has joined #ocaml
serge has quit [Ping timeout: 265 seconds]
ocaml459 has joined #ocaml
<Armael>
Leonidas: woo nice job on the systemd-trolling post on lobsters
<Armael>
you expressed my thoughts exactly
<Armael>
it's really magical how the thread unfolds
<companion_cube>
♥ Leonidas
ocaml459 has quit [Client Quit]
<Armael>
the "oh no, a PARSER" is really funny, given how bad shell is on that aspect
<Leonidas>
likewise, when I read the "good" example of using shell there for a moment I wasn't sure they were being serious so Armael's response is the only sensible answer
<Leonidas>
He literally writes that he knows nothing about it so he claims it sucks.
<Armael>
:D yeah, but what can you do *shrug*
<companion_cube>
tbh I wouldn't mind a somewhat simpler systemd-like in rust
<companion_cube>
but you can pry units from my cold dead hands
<Armael>
yeah, I don't care so much for systemd itself than for the declarative units and the useful baked-in features
<Armael>
I wouldn't mind something else (not written in C for instance) with that features
<companion_cube>
right? and how hard is it to write a init parser…
<Leonidas>
I agree, picking C is an odd choice and it seems to be written in a pretty crappy way, given how often issues get reported
<companion_cube>
(which is more or lss the syntax)
<Armael>
but then I find it strange that alternatives seem to focus on shell scripts or similar
<companion_cube>
write your init in Coq Armael
<Armael>
sure!
<Armael>
i'll do that over the week end
<Leonidas>
companion_cube: I once enabled some process isolation in an unit file and was laughing to me how many hundreds of lines of unreadable shell that would equal to
<Leonidas>
but it was just one line in the unit file
<Armael>
yes! the isolation features are really nice! and you just have to toggle one or two options
<flux>
OCaml would be quite a suitable language for implementing a systemd as well. in fact, a "second implementation" of systemd would probably be good for everyone involved.
<Leonidas>
to the point it seems feasible to just stick that line into all kinds of unit files and see how much a system can be hardened for free
<Leonidas>
simpson: this actually does somewhat more than necessary :-)
<simpson>
Leonidas: Ah, so it sounds like it would take *less than* a single hundred of lines of unreadable shell.
Serpent7776 has quit [Quit: Leaving]
RalfJ has joined #ocaml
<Leonidas>
simpson: or different ones, I don't know how well bocker does error handling
<Leonidas>
that's often the catch with bash, if you just write the happy path then it is easy and reasonably fun, but handling failure becomes quite difficult since you'll have to start handling failures everywhere and it doesn't compose particularly well
RalfJ has quit [Ping timeout: 272 seconds]
<dash>
I did like that implementation of git in sh recently
<dash>
(appropriately named "shit")
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
<companion_cube>
I haven't even tried the isolation stuff
<companion_cube>
but ocabot runs on systemd (as its siblings) and it's super reliable
mbuf has joined #ocaml
kleisli has quit [Ping timeout: 265 seconds]
RalfJ has joined #ocaml
dhil has joined #ocaml
ocaml459 has joined #ocaml
<dash>
ocaml is special because there's Mirage
ocaml459 has quit [Client Quit]
RalfJ has quit [Ping timeout: 272 seconds]
<mbuf>
Is there a way to dump a list from OCaml to a file, and be able to read it back?
<mbuf>
Or any other data structure?
RalfJ has joined #ocaml
<companion_cube>
feels to me like mirage is moving a bit too fast
<companion_cube>
mbuf: marshal or some deriving thing?
<companion_cube>
(depending on the tradeoff convenience/interop/safety you want)
m_oss has joined #ocaml
<mbuf>
companion_cube, okay
<companion_cube>
ppx_deriving_yojson or whatnot I imagine
<companion_cube>
or writing serializers/deserializers yourself
<Armael>
companion_cube the old geezer
<companion_cube>
(I mean with combinators)
kleisli has joined #ocaml
FreeBirdLjj has joined #ocaml
ocaml459 has joined #ocaml
ocaml459 has quit [Client Quit]
decentpenguin has quit [Ping timeout: 260 seconds]
decentpenguin has joined #ocaml
serge has joined #ocaml
<mbuf>
For "let oc = Stdio.Out_channel.create file in fprintf oc "%s\n" m;", why do I get "Error: Unbound value fprintf" Hint: Did you mean bprintf, ifprintf or sprintf? I am compiling using ocamlfind ocamlc - thread -package base -package core file.ml
serge has quit [Ping timeout: 260 seconds]
<vsiles>
mbuf: maybe `Printf.fprintf` ?
spew has joined #ocaml
<vsiles>
or Stdio.printf
<mbuf>
vsiles, I tried that. It says "Error: Unbound value Printf.fpritf"
<companion_cube>
^ typo
<companion_cube>
you forgot an 'n'
<mbuf>
vsiles, same for Stdio.fprintf.
<mbuf>
Same for Printf.fprintf
<companion_cube>
seems like sometimes the stdlib is simpler 🙃
<vsiles>
can replicate here
<vsiles>
mbuf: for the Stdio version, the right name is Stdio.Out_channel.fprintf
<mbuf>
vsiles, yes, just tried it now, and it works.
<mbuf>
vsiles, also, had to use Stdio.Out_channel.close