adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.06.0 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.06/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
ryyppy has joined #ocaml
ryyppy has quit [Ping timeout: 240 seconds]
FreeBirdLjj has joined #ocaml
freusque has joined #ocaml
zmzm has quit [Quit: zmzm]
Guest96936 has quit [Remote host closed the connection]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tokomak has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
kvda has joined #ocaml
dedgrant_ has quit [Quit: Leaving]
kvda has quit [Client Quit]
kvda has joined #ocaml
ryyppy has joined #ocaml
kvda has quit [Client Quit]
ryyppy has quit [Ping timeout: 240 seconds]
phase__ has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 260 seconds]
phase__ has quit [Client Quit]
phase__ has joined #ocaml
phase__ has quit [Client Quit]
phvse has joined #ocaml
kvda has joined #ocaml
freusque has quit [Ping timeout: 244 seconds]
mfp has quit [Ping timeout: 240 seconds]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
kvda has quit [Client Quit]
al-damiri has quit [Quit: Connection closed for inactivity]
kvda has joined #ocaml
kvda has quit [Client Quit]
neatonk has quit [Ping timeout: 265 seconds]
kvda has joined #ocaml
FreeBirdLjj has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ygrek has joined #ocaml
neatonk has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
neatonk has quit [Remote host closed the connection]
kleimkuhler has joined #ocaml
neatonk has joined #ocaml
tormen has joined #ocaml
freusque has joined #ocaml
tormen_ has quit [Ping timeout: 260 seconds]
pierpa has quit [Quit: Page closed]
jlongster has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
FreeBirdLjj has quit [Ping timeout: 265 seconds]
keep_learning has joined #ocaml
keep_learning has quit [Client Quit]
kvda has joined #ocaml
freusque has quit [Quit: WeeChat 2.1]
pierpal has quit [Quit: Poof]
kleimkuhler has quit [Quit: kleimkuhler]
pierpal has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
bartholin has quit [Ping timeout: 264 seconds]
bartholin has joined #ocaml
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kvda has joined #ocaml
mbuf has joined #ocaml
FreeBirdLjj has joined #ocaml
keep_learning has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 268 seconds]
keep_learning has quit [Client Quit]
lostman has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
jnavila has joined #ocaml
ygrek has joined #ocaml
jnavila has quit [Remote host closed the connection]
keep_learning has joined #ocaml
keep_learning has quit [Client Quit]
ygrek has quit [Ping timeout: 244 seconds]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
zolk3ri has joined #ocaml
orbifx has joined #ocaml
cbot has quit [Quit: Leaving]
ryyppy has joined #ocaml
jbrown has quit [Ping timeout: 256 seconds]
ryyppy has quit [Ping timeout: 256 seconds]
FreeBirdLjj has joined #ocaml
sagotch has joined #ocaml
orbifx1 has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 244 seconds]
kakadu has joined #ocaml
orbifx1 has quit [Ping timeout: 240 seconds]
jaar has joined #ocaml
orbifx has quit [Ping timeout: 264 seconds]
jbrown has joined #ocaml
freyr69 has joined #ocaml
pierpal has quit [Ping timeout: 260 seconds]
orbifx has joined #ocaml
orbifx1 has joined #ocaml
dhil has joined #ocaml
maufred has quit [Ping timeout: 260 seconds]
orbifx has quit [Ping timeout: 260 seconds]
<companion_cube> ZirconiumX: not sure, tbh — maybe a submodule?
argent_smith has joined #ocaml
maufred has joined #ocaml
muratiku has joined #ocaml
ryyppy has joined #ocaml
jaar has quit [Ping timeout: 256 seconds]
jbrown has quit [Ping timeout: 244 seconds]
muratiku has quit [Ping timeout: 248 seconds]
ryyppy has quit [Ping timeout: 260 seconds]
neatonk has quit [Remote host closed the connection]
neatonk has joined #ocaml
jaar has joined #ocaml
FreeBirdLjj has joined #ocaml
BitPuffin has joined #ocaml
Haudegen has joined #ocaml
shinnya has quit [Ping timeout: 256 seconds]
bentxt has joined #ocaml
jaar has quit [Remote host closed the connection]
jaar has joined #ocaml
lostman has quit [Quit: Connection closed for inactivity]
FreeBirdLjj has quit [Ping timeout: 256 seconds]
mfp has joined #ocaml
<xvilka> hi
<xvilka> 1) You might want to update the channel topic
<xvilka> 2) Is it possible to coerce bigarray to another type?
<companion_cube> there are no "coercions" in OCaml, so no
<xvilka> e.g. (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t to (uint32, int32_unsigned_elt, c_layout) Bigarray.Array1.t?
<xvilka> basically I need to fill the bigarray.array1 (char) with 4-bytes long integers, like Bigarray.Array1.fill
<xvilka> but recursively copying would be slow
<xvilka> So idea was to coerce somehow char array1 to int32 array1
pierpal has joined #ocaml
<xvilka> and then use Bigarray.Array1.fill function
muratiku has joined #ocaml
TheLemonMan has joined #ocaml
bentxt has quit [Remote host closed the connection]
jaar has quit [Remote host closed the connection]
jaar has joined #ocaml
<companion_cube> this seems pretty unsafe, no idea
bentxt has joined #ocaml
c4rc4s has quit [Excess Flood]
c4rc4s has joined #ocaml
ryyppy has joined #ocaml
FreeBirdLjj has joined #ocaml
jaar has quit [Remote host closed the connection]
jaar has joined #ocaml
shinnya has joined #ocaml
bentxt has quit [Remote host closed the connection]
jaar has quit [Remote host closed the connection]
jaar has joined #ocaml
demonimin has quit [Ping timeout: 240 seconds]
demonimin has joined #ocaml
tarptaeya has joined #ocaml
jaar has quit [Remote host closed the connection]
kvda has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 264 seconds]
jaar has joined #ocaml
muratiku has quit [Remote host closed the connection]
muratiku has joined #ocaml
dhil has quit [Ping timeout: 244 seconds]
bentxt has joined #ocaml
bentxt has quit [Ping timeout: 260 seconds]
<kakadu> Is it intentional that executables in dune don't have an optional field (cxx-names ...) ?
jaar has quit [Remote host closed the connection]
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
muratiku_ has joined #ocaml
muratiku_ has quit [Remote host closed the connection]
muratiku has quit [Read error: No route to host]
muratiku has joined #ocaml
jaar has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
<ZirconiumX> xvilka: reshape, maybe?
bentxt has joined #ocaml
bentxt has quit [Remote host closed the connection]
bentxt has joined #ocaml
<companion_cube> reshape only changes the shape, not the content, afaict
jaar has quit [Remote host closed the connection]
jaar has joined #ocaml
muratiku_ has joined #ocaml
muratiku has quit [Read error: No route to host]
muratiku_ has quit [Remote host closed the connection]
muratiku has joined #ocaml
Haudegen has quit [Remote host closed the connection]
jaar has quit [Remote host closed the connection]
naeiow has joined #ocaml
jaar has joined #ocaml
FreeBirdLjj has joined #ocaml
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
<naeiow> Learning OCaml and pure FP by writing a toy λ interpreter with an S-expression text syntax. Have got it all working, but have one problem with the function of `token list -> sexp`. The problem is that I don't understand how to return properly on a ListClosing token `)`, aka closing paren. The goal is to do this project with just pure functions, no libraries or preprocessors. I think the bug is on line 15 of this paste:
<naeiow> https://pastebin.com/dvR7FsgS but can't figure it out, without using state. In the bottom you see an example of the output. Another example: `sexp_of_tokens (tokenize "(() ())");;` gives ` - : sexp = List [List [List []]]`. If anyone here is experienced with writing pure tree parsers in OCaml I'd be very thankful for a nudge about the right direction to go!
tarptaeya has quit []
<ZirconiumX> A few things, naeiow
<ZirconiumX> Aside from the code, which I don't know enough about
<ZirconiumX> Generally we don't type annotate our code unless the compiler can't deduce the type
<ZirconiumX> Some people do, and some use .mli files for that
<discord> <Perry> It's fine to type annotate if you feel like it. One just isn't expected to.
<ZirconiumX> I don't think using an anoymous function is idiomatic though
<discord> <Perry> Anyway, my comment on how to write a parser of any kind: write down the formal grammar, then write a recursive descent system that mimics it exactly. The first step is to write down the formal grammar
<discord> <Perry> if you do that, you'll find it is much easier.
<ZirconiumX> So if you're going to type annotate, you'd use `let sexp_of_tokens (tokens : token list) = let rec sexpt_of_tokens ...`
freyr69 has quit [Remote host closed the connection]
<naeiow> Yeah that's all right. I'm adding all the annotations beacuse my homo sapiens brain gets lost otherwise! ZirconiumX that style looks better yes
jaar has quit [Remote host closed the connection]
<ZirconiumX> You get used to not having type annotations after a while
<discord> <Perry> Sometimes it is useful to have annotations. It's nice documentation of what a function does.
<discord> <Perry> Sometimes it's utterly unneeded. 😃
jaar has joined #ocaml
<octachron> naeiow, another generic point: List.nth should only be used under imperious needs. Similarly, uses of `@` should require a short proof that the lenght of the left side argument is small (or even better bounded)
<ZirconiumX> List.nth is a sign you should be using an array
<ZirconiumX> Actually
<ZirconiumX> You don't even need it, do you?
<companion_cube> List.rev_append is better if order doesn't matter
<companion_cube> ZirconiumX: the more experience I get, the more type annotations I write
jaar has quit [Remote host closed the connection]
<companion_cube> nowadays most non-trivial functions in my code are type annotated, at least partly
<ZirconiumX> Count me as a newbie, then :p
jaar has joined #ocaml
<companion_cube> let f x (y:foo) : _ option = …
<companion_cube> helps reading code, helps cornering the errors in a small area
muratiku_ has joined #ocaml
muratiku has quit [Read error: No route to host]
<ZirconiumX> True, and sometimes I have type annotated stuff where the compiler gets it wrong
muratiku_ has quit [Read error: Connection reset by peer]
<ZirconiumX> Or just when there are errors
muratiku has joined #ocaml
<ZirconiumX> naeiow: Here's how I would write that code. https://pastebin.com/NYAJBmkP
<ZirconiumX> Feel free to ask questions
<ZirconiumX> Actually, my code is incorrect
<ZirconiumX> Give me a bit
jaar has quit [Remote host closed the connection]
jaar has joined #ocaml
<naeiow> Yeah. The code being cluttered with type anns, and using inefficient data structures is not my problem at the moment. Not optimizing this. The problem with the code is that on a `)` character in the lisp text input puts the next coming thing next to it, not above. So currently `(() ())` becomes `((()))`. In JSON that'd be `[[], []]` which due to my not understanding pure FP parsing becomes `[[[]]]`
jbrown has joined #ocaml
<companion_cube> but now I quite like annotating types in OCaml
<ZirconiumX> naeiow: Here's some code without List.nth (and more importantly, correct) https://pastebin.com/TTncgZzj
<companion_cube> I'd recommend not `foo @ [x]` all the time, though
<ZirconiumX> Can you put the code in a GitHub repo or a tarball to build and test with?
<companion_cube> looks like you can prepend and reverse at the end instead
<ZirconiumX> Or is this literally run under the interpreter?
<octachron> naeiow, hint: the problem starts at ListOpening. When do you expect the inner parser call to stop inside the token stream?
<discord> <Perry> octachron: who runs caml.inria.fr?
<discord> <Perry> I'd like to get them to re-run the 4.07 documentation build with the new Hevea.
<octachron> Perry, if i remember correctly, this requires only to update hevea and rerun the manual generation?
<discord> <Perry> correct. nothing else is needed.
<discord> <Perry> It just works if you update Hevea, and the latest Hevea is in opam now.
<naeiow> This is the code for `parser.ml`. Have not put it on github or anything as it's just a project for learning https://pastebin.com/J168b97P
<naeiow> octachron: hmmmm I meant for that to happen in `EndOfTransmission` and `ListClosing` paths - but obviously I'm not correct about it
<rgr[m]> kakadu: yes, it's intentional. you wil need to define libraries for stubs. It's just to keep things simpler in dune itself
gareppa has joined #ocaml
<ZirconiumX> Right, this is about as idiomatic and clean as I think I can get it: https://pastebin.com/VmiA9xfX
dhil has joined #ocaml
naeiow` has joined #ocaml
muratiku_ has joined #ocaml
jaar has quit [Quit: Leaving]
muratiku_ has quit [Read error: Connection reset by peer]
muratiku has quit [Read error: No route to host]
muratiku has joined #ocaml
naeiow has quit [Ping timeout: 265 seconds]
<Leonidas> is there a way to write a function that takes a polymorphic variant, handles some variants in some way and returns the rest?
<Leonidas> sort of like a set difference
<ZirconiumX> In what context?
<rks`> Leonidas: yes
Haudegen has joined #ocaml
<Leonidas> ZirconiumX: Say I have a function returning [`Ok | `Common_type_of_errors | `Specific_error] I want to have a function which would take this as input, handle `Common_type_of_errors and return [`Ok | `Specific_error] to be handled in a specific way.
<rks`> (that description seems kind of backwards, but whatever)
<ZirconiumX> Couldn't you just use a match statement?
<Leonidas> If I could describe it better I would probably be able to find something with google :-)
<ZirconiumX> Well, expression, but yeah
<rks`> # type t = [ `Ok | `Common | `Specific ] let f : t -> _ = function `Common -> `Ok | (`Ok | `Specific) as rest -> rest;;
<rks`> type t = [ `Common | `Ok | `Specific ]
<rks`> val f : t -> [> `Ok | `Specific ] = <fun>
<ZirconiumX> Was basically what I was thinking, yeah
<Leonidas> ZirconiumX: yes, that's what I am doing. But I have the same error in dozens of cases and always handle it the same way and would like to deduplicate
FreeBirdLjj has quit [Ping timeout: 276 seconds]
<Leonidas> yes, but the input set of variants can be different things
<rks`> Leonidas: as I said, you seem to be doing things the wrong way around
<rks`> write a function handling your specific cases
<rks`> and call that from the more general one
<rks`> let f = function `Ok -> () | `Common -> print "lol" | otherwise -> my_specialized_error_handling_fun otherwise
<Leonidas> and I have handler functions which often return `Mysql_error or `Method_not_allowed or similar
_andre has joined #ocaml
<Leonidas> so I want to handle these always the same way
* bartholin realizes there are weak polymorphic variants.
<ZirconiumX> Leonidas: So have a function like rks' for each error, and then chain them
dhil has quit [Ping timeout: 260 seconds]
mk9 has joined #ocaml
mbuf has quit [Quit: Leaving]
spew has joined #ocaml
<kakadu> Folks, if the guy is PhD student for some Univesity, is it OK to pay for `student` (non-professional) ICFP registration?
al-damiri has joined #ocaml
<Leonidas> ZirconiumX: good idea, but I just tried it and it still has exhaustiveness warnings:
<Leonidas> it complains about me not handling `X and `Y in the continue case.
jlongster has joined #ocaml
<Leonidas> the problem stems from val handle_x : ([> `X ] as 'a) resp -> 'a resp = <fun> where it does not figure out that 'a does not contain `X anymore :(
<theblatte> kakadu: yes
<octachron> Leonidas, you cannot remove a case from an open variant types. As an alternative, you can make the type information flow from the top level function: "function | #xy as x -> handle_xy x | `Z -> ..."
<octachron> kakadu, I think it should be alright?
<kakadu> Yeah, it shouldbe OK
<kakadu> thgx
<kakadu> thx*
shinnya has quit [Ping timeout: 264 seconds]
mk9 has quit [Ping timeout: 248 seconds]
TheLemonMan has joined #ocaml
<Leonidas> octachron: yeah, thanks, this is what I ended up doing :-)
mk9 has joined #ocaml
FreeBirdLjj has joined #ocaml
naeiow` has quit [Ping timeout: 265 seconds]
naeiow` has joined #ocaml
mk9 has quit [Quit: mk9]
warriors has joined #ocaml
bentxt has quit [Remote host closed the connection]
bentxt has joined #ocaml
goose- has joined #ocaml
ryyppy has quit [Ping timeout: 240 seconds]
ryyppy has joined #ocaml
sagotch has quit [Ping timeout: 260 seconds]
sagotch has joined #ocaml
mk9 has joined #ocaml
dhil has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
bentxt has quit [Remote host closed the connection]
naeiow` has quit [Remote host closed the connection]
ziyourenxiang has quit [Ping timeout: 244 seconds]
bentxt has joined #ocaml
ryyppy has quit [Ping timeout: 256 seconds]
kvda has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbifx has joined #ocaml
orbifx1 has quit [Ping timeout: 244 seconds]
bentxt has quit [Remote host closed the connection]
bentxt has joined #ocaml
sagotch has quit [Read error: Connection reset by peer]
gtrak has joined #ocaml
neatonk has quit [Remote host closed the connection]
FreeBirdLjj has quit [Remote host closed the connection]
neatonk has joined #ocaml
FreeBirdLjj has joined #ocaml
gareppa has quit [Quit: Leaving]
orbifx1 has joined #ocaml
orbifx has quit [Ping timeout: 240 seconds]
jnavila has joined #ocaml
mk9 has quit [Quit: mk9]
bentxt has quit [Remote host closed the connection]
dhil has quit [Ping timeout: 256 seconds]
muratiku_ has joined #ocaml
muratiku has quit [Ping timeout: 276 seconds]
dedgrant has joined #ocaml
dedgrant_ has joined #ocaml
mikeyhc has quit [Ping timeout: 240 seconds]
bentxt has joined #ocaml
bentxt has quit [Ping timeout: 264 seconds]
muratiku_ has quit [Remote host closed the connection]
jao has joined #ocaml
jnavila has quit [Ping timeout: 244 seconds]
kakadu has quit [Quit: Konversation terminated!]
malina has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
jnavila has joined #ocaml
bentxt has joined #ocaml
orbifx has joined #ocaml
bentxt has quit [Ping timeout: 244 seconds]
orbifx1 has quit [Read error: Connection reset by peer]
orbifx has quit [Read error: Connection reset by peer]
orbifx1 has joined #ocaml
orbifx has joined #ocaml
orbifx1 has quit [Ping timeout: 268 seconds]
zolk3ri has quit [Ping timeout: 260 seconds]
al-damiri has quit [Quit: Connection closed for inactivity]
zolk3ri has joined #ocaml
mk9 has joined #ocaml
orbifx has quit [Read error: Connection reset by peer]
orbifx has joined #ocaml
Haudegen has quit [Remote host closed the connection]
kakadu has joined #ocaml
mk9 has quit [Quit: mk9]
doppler has joined #ocaml
malina has quit [Ping timeout: 260 seconds]
doppler has left #ocaml [#ocaml]
isd has joined #ocaml
orbifx has quit [Quit: Quit]
nicoo has quit [Ping timeout: 250 seconds]
ygrek has joined #ocaml
nicoo has joined #ocaml
neatonk1 has joined #ocaml
neatonk has quit [Ping timeout: 240 seconds]
neatonk1 is now known as neatonk
malina has joined #ocaml
muratiku has joined #ocaml
jlongster has quit [Quit: Textual IRC Client: www.textualapp.com]
malina has quit [Ping timeout: 260 seconds]
sgnb has quit [Ping timeout: 240 seconds]
sgnb has joined #ocaml
granttrec has joined #ocaml
_andre has quit [Quit: leaving]
Haudegen has joined #ocaml
granttrec has quit [Ping timeout: 252 seconds]
pierpal has quit [Quit: Poof]
pierpal has joined #ocaml
moei has quit [Quit: Leaving...]
bentxt has joined #ocaml
pierpal has quit [Read error: Connection reset by peer]
pierpal has joined #ocaml
pierpa has joined #ocaml
spew has quit [Quit: going home]
dedgrant has quit [Quit: Leaving]
pierpal has quit [Read error: Connection reset by peer]
shinnya has joined #ocaml
goose- has left #ocaml [#ocaml]
ygrek has quit [Remote host closed the connection]
ygrek has joined #ocaml
ryyppy has joined #ocaml
ryyppy has quit [Ping timeout: 244 seconds]
ryyppy has joined #ocaml
muratiku has quit [Remote host closed the connection]
malina has joined #ocaml
ryyppy has quit [Ping timeout: 264 seconds]
moei has joined #ocaml
mk9 has joined #ocaml
mk9 has quit [Client Quit]
kakadu has quit [Remote host closed the connection]
muratiku has joined #ocaml
gtrak has quit [Ping timeout: 240 seconds]
neatonk has quit [Ping timeout: 260 seconds]
jao has quit [Ping timeout: 244 seconds]
ryyppy has joined #ocaml
mk9 has joined #ocaml
spew has joined #ocaml
ryyppy has quit [Ping timeout: 264 seconds]
bentxt has quit []
ben__ has joined #ocaml
dhil has joined #ocaml
muratiku has quit [Remote host closed the connection]
gtrak has joined #ocaml
spew has quit [Ping timeout: 260 seconds]
dhil has quit [Ping timeout: 260 seconds]
gtrak has quit [Quit: WeeChat 2.1]
Haudegen has quit [Read error: Connection reset by peer]
mk9 has quit [Quit: mk9]
kleimkuhler has joined #ocaml
kleimkuhler has quit [Client Quit]
jnavila has quit [Remote host closed the connection]
kleimkuhler has joined #ocaml
kleimkuhler has quit [Client Quit]
pierpal has joined #ocaml
isd has quit [Quit: Leaving.]