News for hackers. Stuff that matters.
Re:Beating Decades of Optimized C with 80 Lines of Haskell by gpderetta on Wednesday October 16, 2019 @06:31AM (#21268887)
Nice.

I was going to say that it is unreadable, after spending a bit trying to understand it, (for someone that knows no ocaml) it actually is not. Only things I'm unsure are the ~ symbol and <-. What do they do?

edit: <- is just mutating assignment. I thought that ~ introduced named arguments but doesn't seem right.

Re:Beating Decades of Optimized C with 80 Lines of Haskell by pcstl on Wednesday October 16, 2019 @11:46AM (#21271670)
~ does indeed denote named arguments. To call a function named f which has an argument named arg with arg set to the value x, the syntax is:

    f ~arg:x
Re:Beating Decades of Optimized C with 80 Lines of Haskell by gpderetta on Wednesday October 16, 2019 @12:33PM (#21272285)
But what about ~buf here:

  let len = Core.In_channel.input in_ch ~buf ~pos:0 ~len:buf_size
Re:Beating Decades of Optimized C with 80 Lines of Haskell by test9753 on Wednesday October 16, 2019 @01:09PM (#21272756)
~buf is shorthand for ~buf:buf
Re:Beating Decades of Optimized C with 80 Lines of Haskell by gpderetta on Wednesday October 16, 2019 @01:18PM (#21272849)
Oh, nice.