<ristos>
and if there is more than one `show` with the same signature like `int -> string` it just throws an error
<Drup>
ristos: lookup ppx_implicits
<ristos>
yeah I saw that project, but it wasn't exactly the syntax I was looking for
swalk has joined #ocaml
<Drup>
Unless you are familiar with the typechecker and/or want to have fun, I would not advise trying to write something like that by yourself, it's quite non trivial. :)
<Drup>
(also, really using that in your code is a terrible idea, but that's another question)
<ristos>
ppx_implicits? is it not mature enough or just a toy project?
<Leonidas>
are you trying to implement modular implicits on your own?
<Drup>
It will never be mature, by definition. By essence, it's just a hack.
<ristos>
I didn't like that it had so much haskellism implied in it... I just want it to dispatch based on the concrete signature, no other special terminology going on
<ristos>
like a much more restricted version of it, because I want to use something like that in bucklescript/reason but modular implicits haven't made it in yet
<ristos>
I was initially trying to merge the modular implicits repo into the bucklescript one to try to make 4.02.3+buckle+implicits, but the merge was way too difficult
<Drup>
Honestly, my advice would be to live without adhoc polymorphism for now :)
<Drup>
Adding adhoc polymorphism to OCaml is not a simple task that you can wipe up quickly in a ppx.
<Leonidas>
ristos: even if MI makes into ocaml, it will probably be a long time till BS picks it up
Fardale has quit [Quit: J'ai perdu]
tobiasBora has quit [Quit: Kthxbye]
_y has quit [Read error: Connection reset by peer]
<ristos>
octachron Yeah but I didn't see anything there that I could use for what I'm trying to do. What do you think I can take from it?
jao has joined #ocaml
swalk has quit [Quit: swalk]
ziyourenxiang has quit [Quit: Leaving]
ziyourenxiang has joined #ocaml
jlongster has joined #ocaml
<octachron>
ristos, implementing adhoc polymorphism in Ocaml is a quite sisyphean task since it goes againts the very idea of type abstraction and OCaml module system
<octachron>
it is often better to embrace explicitness and the module system: rather than trying to implement a polymorphic show, use the module system and a bit of syntax sugar to make it easier to compose show function
bronsen has joined #ocaml
<Drup>
TIL "sisyphean"
<Drup>
(the #ocaml channel is not only good for your french vocabulary, but your Greek too!)
<reynir>
adrien: I got an error on 4.04.2+flambda, something about floats in non-float arrays. I think it was in libpcre. I switched laptops, but I can send you the exact error when I switch back heh
sh0t has quit [Ping timeout: 268 seconds]
<adrien>
oh, I'm unfortunately going to be completely helpless for such issues
<adrien>
it probably matters to the compiler maintainers however
<Drup>
hmm, libpcre
<reynir>
Heh, no worries. I'm now waiting for plain 4.04.2 is compiled :D
<Drup>
it'll probably not be a dependency of eliom anymore at some point
<reynir>
adrien: Is it correct that I need to install eliom?
<ristos>
octachron I'm a new to ocaml style, how would you get some sugar with the module system for the simple `Show_int` vs `Show_float` `show` example?
FreeBirdLjj has joined #ocaml
<adrien>
reynir: it's one of the depds, yes
dreadedfrog has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 255 seconds]
dreadedfrog has quit [Ping timeout: 246 seconds]
sh0t has joined #ocaml
govg has quit [Ping timeout: 240 seconds]
govg has joined #ocaml
<octachron>
ristos, for your print_endline example? Why not use `Format.printf "%d%f@." 3 3.5` ?
<ristos>
octachron it's just a simple use-case for ad hoc polymorphism
<octachron>
Sure type classes or ad-hoc polymorphism are useful, but they come with the disadvantage of binding data with behavior, which Ocaml tends to avoid
aciniglio has joined #ocaml
<ristos>
why is that a disadvantage?
<octachron>
because the same data can have multiple interpretations, sometimes an integer is an element of the field (ℕ,+,*), sometimes it is an element of the lattice ( ℕ, | )
<octachron>
using the same comparison operations on these two interpretations of integers would be wrong
TheLemonMan has joined #ocaml
samrat_ has quit [Ping timeout: 240 seconds]
sam____ has joined #ocaml
yegods has joined #ocaml
yegods has quit [Ping timeout: 248 seconds]
<ristos>
but you pick what can be dispatched explicitly though
<ristos>
that's the nice thing I like about ocaml modules, you can choose which implementation to use and you get the other abstractions for free
axiles has joined #ocaml
<ristos>
AdditiveMonoidInt vs MultiplicativeMonoidInt, or ConjMonoidBool vs DisjMonoidBool, etc
<ristos>
and you can explicitly say that you accept a dispatch with some keyword, like `implicit` in modular implicits
dreadedfrog has joined #ocaml
MercurialAlchemi has joined #ocaml
ryanartecona has joined #ocaml
dreadedfrog has quit [Ping timeout: 248 seconds]
MercurialAlchemi has quit [Ping timeout: 246 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
sz0 has joined #ocaml
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 276 seconds]
FreeBirdLjj has joined #ocaml
samrat_ has joined #ocaml
tautologico has joined #ocaml
silver has joined #ocaml
ryanartecona has quit [Ping timeout: 255 seconds]
sam____ has quit [Ping timeout: 276 seconds]
dhil has quit [Ping timeout: 268 seconds]
cranmax has joined #ocaml
jpdeplaix has quit [Ping timeout: 260 seconds]
<cranmax>
Hi, I'm trying to parse a CSV that contains two columns with header and the content are numbers, so I have installed the library OCaml CSV.
<cranmax>
I have done like you say, and now the type is Csv.t
ygrek has joined #ocaml
freusque has quit [Quit: WeeChat 1.9]
dhil has joined #ocaml
<shepard>
Ok, Csv.t is basically a list of list of strings
<shepard>
So I guess the first thing you want is get rid of the header, if there is one : let csv = List.tl csv in
<shepard>
now you have a string list list that you want to transform into a float list list
<shepard>
you can do this by let floats = List.map (fun row -> List.map float_of_string row) csv
<shepard>
now you should have a float list list
dreadedfrog has quit [Ping timeout: 240 seconds]
ygrek has quit [Ping timeout: 240 seconds]
<shepard>
oh there is a better way
<shepard>
nevermind, there isn't
<shepard>
I thought you could use the function Csv.map but it takes a (string -> string) argument and not a (string -> 'a) argument.
justicefries has joined #ocaml
artart78_ is now known as artart78
jpdeplaix has joined #ocaml
yegods has joined #ocaml
<cranmax>
Okay, so I do: let csv = List.tl csv;; then the output type is : val csv : string list list option
<cranmax>
and when I do the List.map, outputs an error : This expression should not be a function, the expected type is 'a list
<cranmax>
I think I was using Core library, but I continue having problems; without Core it raises an exceptiion: (Failure float_of_string).
<octachron>
cranmax, if you are using 4.05.0, use "float_of_string_opt", it will output "Some x" if the input was a well formed float and "None" otherwise
<cranmax>
octachron : I'm using 4.04.2
<octachron>
cranmax, note also that float in csv are locale sensitive
yegods has quit [Ping timeout: 276 seconds]
<cranmax>
octachron, the csv are numbers from 1 to 10 and the header is A and B
<cranmax>
I mean that the locale from here, Spain, must be correct
<octachron>
if you have a "sum: float list -> float", then "List.map ~f:sum" will have for type "float list list -> float list", i.e. it will compute the list of sums of the inner lists
sz0 has quit [Quit: Connection closed for inactivity]
<cranmax>
octachron, I understand that the sum function is not correct because has type : float list -> float, and can't be used to sum the type: float list list, or the type: float option list list. Am I correct?
<peterpp__>
when I have `open Async.Std` in my program, then output to stdout stops working
<peterpp__>
why exactly is this?
sepp2k has quit [Remote host closed the connection]
<octachron>
cranmax, rather than not correct, I would say that the "sum" functions only knows how to handle float list's input
enterprisey has joined #ocaml
<cranmax>
yes the "sum" function is correct because I have wrote it as it is =) , but it's not doing what I want
<octachron>
peterpp__, Async.Std redefines most of Pervasives printing function
sepp2k has joined #ocaml
MercurialAlchemi has joined #ocaml
samrat_ has quit [Ping timeout: 240 seconds]
fraggle_ has quit [Read error: Connection reset by peer]
sepp2k has quit [Ping timeout: 240 seconds]
samrat_ has joined #ocaml
aciniglio has quit [Ping timeout: 240 seconds]
malina has quit [Ping timeout: 276 seconds]
<cranmax>
How can I access the list of lists?
<peterpp__>
I'm trying to asynchronously read some rows from an sqlite database and process them in a callback
<peterpp__>
for some reason the callback never gets called as far as I can tell
<octachron>
cranmax, like list you can deconstruct list of list with pattern matching, or use higher-order function like map, fold(_left|_right)
<peterpp__>
octachron, argh... thank you!
dreadedfrog has joined #ocaml
sam____ has quit [Ping timeout: 258 seconds]
maxton has joined #ocaml
dreadedfrog has quit [Ping timeout: 276 seconds]
sz0 has joined #ocaml
dhil has quit [Ping timeout: 240 seconds]
malina has joined #ocaml
<cranmax>
octachron, how can I deconstruct a list of list? I would like to see it with pattern matching, thanks
maxton has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
maxton has joined #ocaml
<octachron>
cranmax, for instance "let rec pair_prod p l = match l with | [] -> p | [Some a; Some b] :: q -> pair_prod (a * b * p) q | _ :: q -> pair_prod p q"
dhil has joined #ocaml
Ragora|Away has quit [Ping timeout: 248 seconds]
<cranmax>
octachron : thanks, I'm trying to understand what it does
Fardale has joined #ocaml
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 255 seconds]
enterprisey has joined #ocaml
dhil has quit [Ping timeout: 268 seconds]
pacak has quit [Ping timeout: 246 seconds]
andreas_ has joined #ocaml
kevinqiu has joined #ocaml
al-damiri has joined #ocaml
samrat_ has quit [Ping timeout: 240 seconds]
sam____ has joined #ocaml
<dxtr>
I love how I'm running in to issue after issue :D
<dxtr>
Now I switched to jbuilder, found a ppx thingy for pgocaml and... It won't compile with jbuilder
pacak has joined #ocaml
<octachron>
dxtr, this is the unfortunate conequence of jbuilder very opiniated stance
<dxtr>
hmm?
<octachron>
dxtr, in the name of efficiency jbuilder requires that ppx extensions use a very recent and specific intermediary library
enterprisey has quit [Remote host closed the connection]
<dxtr>
right
<dxtr>
So the plan for this evening is try to convert the ppx thing to this new stuff
<dxtr>
Hopefully I'll learn something :D
dreadedfrog has joined #ocaml
mengu has joined #ocaml
dreadedfrog has quit [Ping timeout: 246 seconds]
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 255 seconds]
yegods has quit [Remote host closed the connection]
yegods has joined #ocaml
yegods has quit [Remote host closed the connection]
justicefries has left #ocaml [#ocaml]
_y has quit [Ping timeout: 276 seconds]
Fardale has quit [Ping timeout: 276 seconds]
Simn has quit [Quit: Leaving]
dreadedfrog has joined #ocaml
pierpa has joined #ocaml
Fardale has joined #ocaml
_y has joined #ocaml
dreadedfrog has quit [Ping timeout: 246 seconds]
tane has quit [Quit: Leaving]
_andre has quit [Quit: leaving]
raphael has joined #ocaml
raphael has quit [Client Quit]
MercurialAlchemi has quit [Ping timeout: 240 seconds]
raphaelss has joined #ocaml
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
infinity0 has quit [Ping timeout: 248 seconds]
infinity0 has joined #ocaml
copy_ has quit [Quit: Connection closed for inactivity]
jlongster has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 255 seconds]
axiles has quit [Ping timeout: 268 seconds]
axiles has joined #ocaml
mengu has quit [Remote host closed the connection]
<dxtr>
I tried importing Ast_405 but that didn't work
<dxtr>
That is to say; the import didn't work
mengu has quit [Ping timeout: 240 seconds]
sh0t has joined #ocaml
<octachron>
dxtr, the problem is that the ppx_tools.metaquot syntax is using the current version of the Ast, you probably need to convert it back to the version 4.04, or have a look at janestreet's ppx_metaquot
<dxtr>
Ah, okay
<dxtr>
Obviously
argent_smith has quit [Ping timeout: 240 seconds]
ygrek has joined #ocaml
<octachron>
dxtr, another solution may be to use ppx_tools/rewriter to apply the metaquot ppx transform and get back AST fragments
jlongster has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kevinqiu has joined #ocaml
mengu has joined #ocaml
kevinqiu has quit [Ping timeout: 268 seconds]
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 260 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
cranmax has quit [Quit: Connection closed for inactivity]
kakadu_ has quit [Remote host closed the connection]