ChanServ changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.02.1 announcement at http://ocaml.org/releases/4.02.html | Public channel logs at http://irclog.whitequark.org/ocaml
prsn has joined #ocaml
beginner has joined #ocaml
beginner has joined #ocaml
MrScout has quit [Ping timeout: 256 seconds]
MrScout has joined #ocaml
claudiuc has quit [Remote host closed the connection]
Simn has quit [Quit: Leaving]
boogie has quit [Remote host closed the connection]
reem_ has quit [Remote host closed the connection]
Guest65209 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
prsn has quit [Ping timeout: 240 seconds]
reem has joined #ocaml
prsn has joined #ocaml
rgrinberg has quit [Ping timeout: 246 seconds]
AltGr has joined #ocaml
flux has joined #ocaml
reem has quit [Remote host closed the connection]
TheLemonMan has quit [Quit: leaving]
MrScout has quit [Remote host closed the connection]
reem has joined #ocaml
madroach has quit [Ping timeout: 240 seconds]
madroach has joined #ocaml
prsn has quit [Ping timeout: 272 seconds]
prsn has joined #ocaml
jprakash has quit [Ping timeout: 272 seconds]
shinnya has quit [Ping timeout: 255 seconds]
prsn has quit [Ping timeout: 250 seconds]
prsn has joined #ocaml
kakadu has joined #ocaml
Algebr has joined #ocaml
<Algebr> It seems that it is possible to add new directives to the toplevel at will, is this some magic that is exposed via compiler-libs?
<dmbaturin> Algebr: There's a way to create custom toplevels, but it doesn't provide facilities for defining new directives AFAIR.
rgrinberg has joined #ocaml
prsn has quit [Ping timeout: 245 seconds]
<Algebr> But #require is not part of the original ocaml toplevel but it works in tuop which uses findlib I assume. So it must have added it somehow?
<Algebr> utop
prsn has joined #ocaml
rgrinberg has quit [Ping timeout: 265 seconds]
<dmbaturin> Algebr: Hhm, there must be a way to do it. Apparently, the require directive comes from findlib, because "#use "topfind";; #require "something"" works.
darkf has joined #ocaml
ghostpl_ has joined #ocaml
yminsky has joined #ocaml
prsn has quit [Ping timeout: 244 seconds]
rgrinberg has joined #ocaml
prsn has joined #ocaml
ghostpl_ has quit [Ping timeout: 244 seconds]
thomasga has quit [Quit: Leaving.]
sdothum has quit [Quit: ZNC - 1.6.0 - http://znc.in]
marynate has joined #ocaml
<dmbaturin> Algebr: Reading findlib source revealed that the toplevel stores directive callbacks in a hashtbl and that you can modify it.
<Algebr> yea, I found it too, the Toploop.directive_table
<dmbaturin> Did you succeed at modifying it?
<Algebr> I haven't added anything to it, but it is a plain ole' hashtable so it should be possible. Looking at utop, it adds quite a bit of stuff as well
rgrinberg has quit [Ping timeout: 264 seconds]
<SGrondin> Anybody here has some experience with ctypes?
prsn has quit [Ping timeout: 264 seconds]
prsn has joined #ocaml
<SGrondin> let hw = foreign "helloworld" (void @-> returning void)
<SGrondin> let hw ()
<SGrondin> ==> Fatal error: exception Dl.DL_error("./abc: undefined symbol: helloworld")
<SGrondin> And my helloworld.c:
<SGrondin> #include<stdio.h>
<SGrondin> void helloworld()
<SGrondin> {
<SGrondin> printf("Hello World");
<SGrondin> }
<whitequark> how do you compile and load this?
<SGrondin> ocamlopt helloworld.c
<SGrondin> corebuild test.native -no-links -no-hygiene -pkg ctypes,ctypes.foreign
<SGrondin> ocamlfind ocamlopt helloworld.o -o abc _build/test.cmx -linkall -linkpkg -package ctypes,ctypes.foreign
ygrek has joined #ocaml
rgrinberg has joined #ocaml
mcc has joined #ocaml
<dmbaturin> Algebr: Interesting. Modifying the directive table succeeds, but calling it gives "unknown directives". I wonder what I'm missing.
<dmbaturin> Perhaps I should read the toplevel source too. :)
kakadu has quit [Remote host closed the connection]
prsn has quit [Ping timeout: 256 seconds]
yminsky has quit [Quit: yminsky]
prsn has joined #ocaml
yminsky has joined #ocaml
beginner has quit [Read error: Connection reset by peer]
beginner has joined #ocaml
beginner has quit [Changing host]
beginner has joined #ocaml
<Algebr> dmbaturin: did you do something like let _ = Hashtbl.add directive_table "use" (Directive_string (dir_use std_out));;
<dmbaturin> Algebr: Yep.
<whitequark> don't link or load compiler-libs.toplevel
<whitequark> or anything from ompiler-libs
<whitequark> you need Topdirs
<whitequark> and Toplevel
mal`` has quit [Ping timeout: 245 seconds]
<dmbaturin> whitequark: So the Toplevel module is not from compiler-libs?
<dmbaturin> Loading compiler-libs.toplevel is exactly what I did.
shinnya has joined #ocaml
<whitequark> don't do that
<whitequark> Toplevel is both in compiler-libs and not in compiler-libs
<whitequark> and it has global state which interacts with the rest of the runtime in extremely awkward ways
<whitequark> just... when in toplevel, forget that c-l.toplevel even exists
<whitequark> you only have those two modules. that is all.
mal`` has joined #ocaml
<dmbaturin> whitequark: Hhm, without it I get unbound module error (about Toplevel).
<whitequark> Toploop
<whitequark> not Toplevel
<dmbaturin> * Toploop, of course.
marynate has quit [Quit: Leaving]
<whitequark> do you compile and #load or #use?
prsn has quit [Ping timeout: 245 seconds]
prsn has joined #ocaml
<dmbaturin> The code that mangles the directive table? I #use it.
<whitequark> in raw toplevel
<whitequark> # Toploop.directive_table;;
<whitequark> - : (string, Toploop.directive_fun) Hashtbl.t = <abstr>
<dmbaturin> Did anything change since 4.01?
<whitequark> this works in 4.01
<whitequark> oh, wait
<Algebr> I guess there is no math module, so all math that comes with ocaml is just dumped in Pervasives?
<whitequark> you need #directory "+compiler-libs";;
<whitequark> Algebr: some is in Int64
<Algebr> whitequark: thanks, also what is the + for ?
shinnya has quit [Ping timeout: 265 seconds]
<dmbaturin> whitequark: Ah, thanks, now it works. Some time I'm going to figure out what exactly the awkward ways it interacts with toplevel are.
<Algebr> Oh derp, it probably just means add right? is there a - as well?
<Algebr> I wrote a recursive function to find pi with a given tolerance of epsilon_float, which I understand is the smallest float that the machine can reliably deal with , but the function finishes in just 4 iterations...which is kind of suspect. Is there some kind of BigFloat I can use to get even more precision? I'm only getting these many digits: 3.14159265359
<bernardofpc> Algebr: what is your algorithm like ?
<Algebr> http://en.wikipedia.org/wiki/Gauss–Legendre_algorithm
<bernardofpc> (these are all exact digits of pi)
<whitequark> Algebr: noooope
<whitequark> it means "path relative to ocaml stdlib"
<whitequark> #remove_directory does the opposite
<Algebr> whitequark: oh wow, that is some wacky convention
<bernardofpc> Algebr: well, the standard way is to use Rational numbers and then only at the end project onto the reals
<Algebr> I don't get it, floats are just rationals.
<bernardofpc> there is gmp.mpfr for the latter and I don't know for Rational, but in either case you can easily program that with two gmp.mpz's
<Algebr> hmm, don't even know what gmp.* is, will have to google some.
<bernardofpc> gnu multi-precision library
<bernardofpc> there are two bindings for it, Zarith for only integers, and mlgmp for all of them, but probably not as good as ZArith
<Algebr> I see, so are you basically saying use ocaml bindings to it
<Algebr> ah
<bernardofpc> in your case, I'd probably use mlgmp
prsn has quit [Ping timeout: 246 seconds]
<bernardofpc> but I am not very much a fan of OCaml in numerical code
prsn has joined #ocaml
<Algebr> why? anything more besides the annoyance of separate operators for floats/ints?
yminsky has quit [Quit: yminsky]
<bernardofpc> it's slow
<bernardofpc> I mean, being 2x slower than C for int-only code is really not good
<bernardofpc> I don't know about floating point
<bernardofpc> and I have recently made a micro-benchmark of ZArith vs C+mpz, and C was 6x faster
prsn has quit [Ping timeout: 252 seconds]
<dmbaturin> Are there any examples of code with Lwt and socket multiplexing?
prsn has joined #ocaml
ghostpl_ has joined #ocaml
ghostpl_ has quit [Ping timeout: 265 seconds]
ygrek has quit [Ping timeout: 245 seconds]
<Algebr> the code in mlgmp is pretty outdated it seems
ygrek has joined #ocaml
prsn has quit [Ping timeout: 252 seconds]
prsn has joined #ocaml
ygrek has quit [Ping timeout: 246 seconds]
rgrinberg has quit [Ping timeout: 264 seconds]
prsn has quit [Ping timeout: 244 seconds]
prsn has joined #ocaml
pyon has quit [Quit: I'm sorry but... I don't have any interest in three-dimensional girls.]
Algebr has quit [Ping timeout: 256 seconds]
rgrinberg has joined #ocaml
pyon has joined #ocaml
rgrinberg has quit [Ping timeout: 246 seconds]
rgrinberg has joined #ocaml
ggole has joined #ocaml
prsn has quit [Ping timeout: 264 seconds]
iorivur has joined #ocaml
prsn has joined #ocaml
iorivur has quit [Ping timeout: 265 seconds]
prsn has quit [Ping timeout: 265 seconds]
prsn has joined #ocaml
nullcat has joined #ocaml
prsn has quit [Ping timeout: 245 seconds]
prsn has joined #ocaml
beginner has quit [Read error: Connection reset by peer]
beginner has joined #ocaml
reem has quit [Ping timeout: 246 seconds]
ghostpl_ has joined #ocaml
prsn has quit [Ping timeout: 245 seconds]
ghostpl_ has quit [Ping timeout: 246 seconds]
prsn has joined #ocaml
Bhavya has joined #ocaml
reem has joined #ocaml
prsn has quit [Ping timeout: 250 seconds]
prsn has joined #ocaml
govg has quit [Quit: leaving]
MrScout_ has joined #ocaml
MrScout_ has quit [Read error: Connection reset by peer]
MrScout_ has joined #ocaml
ygrek has joined #ocaml
prsn has quit [Ping timeout: 244 seconds]
prsn has joined #ocaml
reem has quit [Remote host closed the connection]
nullcat has quit [Read error: Connection reset by peer]
Bhavya has quit [Ping timeout: 252 seconds]
nullcat has joined #ocaml
reem has joined #ocaml
prsn has quit [Ping timeout: 255 seconds]
prsn has joined #ocaml
Bhavya has joined #ocaml
shinnya has joined #ocaml
prsn has quit [Ping timeout: 250 seconds]
prsn has joined #ocaml
reem has quit [Remote host closed the connection]
psy_ has quit [Remote host closed the connection]
reem has joined #ocaml
MercurialAlchemi has joined #ocaml
MrScout_ has quit [Ping timeout: 256 seconds]
prsn has quit [Ping timeout: 246 seconds]
prsn has joined #ocaml
slash^ has joined #ocaml
ghostpl_ has joined #ocaml
reem has quit [Remote host closed the connection]
rgrinberg has quit [Ping timeout: 252 seconds]
ghostpl_ has quit [Ping timeout: 245 seconds]
reem has joined #ocaml
prsn has quit [Ping timeout: 246 seconds]
prsn has joined #ocaml
reem has quit [Remote host closed the connection]
reem has joined #ocaml
myst|work has quit [Ping timeout: 244 seconds]
rossberg has quit [Ping timeout: 265 seconds]
Nijikokun has joined #ocaml
Nijikokun has quit [Max SendQ exceeded]
Nijikokun has joined #ocaml
reem has quit [Remote host closed the connection]
AlexRussia has quit [Ping timeout: 245 seconds]
prsn has quit [Ping timeout: 252 seconds]
pyon has quit [Ping timeout: 264 seconds]
prsn has joined #ocaml
kakadu has joined #ocaml
mcc has quit [Quit: This computer has gone to sleep]
prsn has quit [Ping timeout: 246 seconds]
prsn has joined #ocaml
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
reem has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Ping timeout: 252 seconds]
AlexRussia has joined #ocaml
SGrondin has left #ocaml [#ocaml]
Nijikokun has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
prsn has quit [Ping timeout: 265 seconds]
Simn has joined #ocaml
prsn has joined #ocaml
tane has joined #ocaml
destrius has joined #ocaml
<kakadu> Do you know what is GPR#137 in ocaml change-list?
<kakadu> PR#12341234 is about mantis. What does G mean?
<kakadu> Ah, Github pull request
prsn has quit [Ping timeout: 246 seconds]
prsn has joined #ocaml
ghostpl_ has joined #ocaml
prsn has quit [Ping timeout: 264 seconds]
ghostpl_ has quit [Ping timeout: 256 seconds]
prsn has joined #ocaml
reem has quit [Remote host closed the connection]
AltGr has left #ocaml [#ocaml]
myst|work has joined #ocaml
reem has joined #ocaml
prsn has quit [Ping timeout: 255 seconds]
prsn has joined #ocaml
xificurC has joined #ocaml
Intensity has quit [Ping timeout: 244 seconds]
Intensity has joined #ocaml
Intensity has quit [Remote host closed the connection]
prsn has quit [Ping timeout: 272 seconds]
prsn has joined #ocaml
<companion_cube> bernardofpc: Zarith provides integers and rationals
rossberg has joined #ocaml
Intensity has joined #ocaml
reem has quit [Remote host closed the connection]
rgrinberg has joined #ocaml
rossberg has quit [Ping timeout: 245 seconds]
reem has joined #ocaml
prsn has quit [Ping timeout: 272 seconds]
rgrinberg has quit [Ping timeout: 255 seconds]
prsn has joined #ocaml
rossberg has joined #ocaml
reem has quit [Remote host closed the connection]
reem has joined #ocaml
nuki has joined #ocaml
<nuki> Excuse me @gasche, it's possible to do JOIN in Macaque ? (thanks)
freling has joined #ocaml
Bhavya has quit [Quit: Quit the channel]
reem has quit [Remote host closed the connection]
reem has joined #ocaml
reem has quit [Remote host closed the connection]
paradoja has joined #ocaml
prsn has quit [Ping timeout: 256 seconds]
prsn has joined #ocaml
reem has joined #ocaml
matason has joined #ocaml
<nuki> Ah yes, with "generator chaining :v"
Nijikokun has joined #ocaml
Nijikokun has quit [Max SendQ exceeded]
matason has quit [Ping timeout: 265 seconds]
prsn has quit [Ping timeout: 246 seconds]
beginner has quit [Read error: Connection reset by peer]
reem has quit [Remote host closed the connection]
beginner has joined #ocaml
prsn has joined #ocaml
ghostpl_ has joined #ocaml
reem has joined #ocaml
rossberg_ has joined #ocaml
rossberg has quit [Ping timeout: 246 seconds]
myst|work has quit [Ping timeout: 272 seconds]
myst|work has joined #ocaml
ghostpl_ has quit [Ping timeout: 240 seconds]
Haudegen has quit [Ping timeout: 240 seconds]
pyon has joined #ocaml
prsn has quit [Ping timeout: 256 seconds]
prsn has joined #ocaml
breadmonster has joined #ocaml
Haudegen has joined #ocaml
pyon has quit [Ping timeout: 272 seconds]
Haudegen has quit [Ping timeout: 245 seconds]
pyon has joined #ocaml
prsn has quit [Ping timeout: 246 seconds]
mort___ has joined #ocaml
rossberg has joined #ocaml
prsn has joined #ocaml
beginner has quit [Read error: Connection reset by peer]
beginner has joined #ocaml
myst|work has quit [Ping timeout: 252 seconds]
rossberg_ has quit [Ping timeout: 245 seconds]
Anarchos has joined #ocaml
myst|work has joined #ocaml
Haudegen has joined #ocaml
sdothum has joined #ocaml
reem has quit [Remote host closed the connection]
JuggleTux has quit [Ping timeout: 245 seconds]
prsn has quit [Ping timeout: 250 seconds]
prsn has joined #ocaml
rgrinberg has joined #ocaml
meteo has quit [Ping timeout: 252 seconds]
meteo has joined #ocaml
rgrinberg has quit [Ping timeout: 245 seconds]
Haudegen has quit [Ping timeout: 252 seconds]
thomasga has joined #ocaml
prsn has quit [Ping timeout: 256 seconds]
prsn has joined #ocaml
Haudegen has joined #ocaml
cdidd_ has joined #ocaml
cdidd has quit [Ping timeout: 256 seconds]
Haudegen has quit [Ping timeout: 272 seconds]
lordkryss has joined #ocaml
cdidd_ is now known as cdidd
Haudegen has joined #ocaml
shinnya has quit [Ping timeout: 245 seconds]
TheLemonMan has joined #ocaml
ghostpl_ has joined #ocaml
rgrinberg has joined #ocaml
prsn has quit [Ping timeout: 256 seconds]
prsn has joined #ocaml
rgrinberg has quit [Ping timeout: 272 seconds]
ghostpl_ has quit [Ping timeout: 246 seconds]
AlexRussia has quit [Quit: WeeChat 1.2-dev]
Anarchos has quit [Quit: Vision[0.9.7-H-20140108]: i've been blurred!]
iorivur has joined #ocaml
vivien_ has joined #ocaml
psy_ has joined #ocaml
prsn has quit [Ping timeout: 240 seconds]
yminsky has joined #ocaml
beginner has quit [Read error: Connection reset by peer]
beginner has joined #ocaml
prsn has joined #ocaml
<breadmonster> Is there an equivalent of parsec for OCaml?
<kakadu> there are some libraries
<kakadu> not exactly equivalent
<kakadu> AFAIR planck
Guest32856 has joined #ocaml
<kakadu> and, if you are not afraid of camlp5, ostap
rgrinberg has joined #ocaml
vivien_ has quit [Quit: Konversation terminated!]
martintrojer has quit [Read error: No route to host]
rgrinberg has quit [Ping timeout: 256 seconds]
prsn has quit [Ping timeout: 264 seconds]
prsn has joined #ocaml
yminsky has quit [Quit: yminsky]
<breadmonster> kakadu: Thanks (:
kakadu has quit [Ping timeout: 246 seconds]
kakadu has joined #ocaml
badkins has joined #ocaml
prsn has quit [Ping timeout: 240 seconds]
prsn has joined #ocaml
oscar_toro has joined #ocaml
mort___ has quit [Quit: Leaving.]
rgrinberg has joined #ocaml
AlexRussia has joined #ocaml
thomasga has quit [Quit: Leaving.]
prsn has quit [Ping timeout: 244 seconds]
prsn has joined #ocaml
rgrinberg has quit [Ping timeout: 255 seconds]
thomasga has joined #ocaml
rgrinberg has joined #ocaml
thomasga has quit [Quit: Leaving.]
thomasga has joined #ocaml
yminsky has joined #ocaml
prsn has quit [Ping timeout: 252 seconds]
rgrinberg has quit [Ping timeout: 252 seconds]
prsn has joined #ocaml
yminsky has quit [Quit: yminsky]
yminsky has joined #ocaml
beginner has quit [Read error: Connection reset by peer]
beginner has joined #ocaml
yminsky has quit [Client Quit]
shinnya has joined #ocaml
ghostpl_ has joined #ocaml
jprakash has joined #ocaml
Guest61842 has quit [Remote host closed the connection]
breadmonster has quit [Quit: Page closed]
yminsky has joined #ocaml
ghostpl_ has quit [Ping timeout: 265 seconds]
yminsky has quit [Client Quit]
JuggleTux has joined #ocaml
prsn has quit [Ping timeout: 250 seconds]
Matt____ has joined #ocaml
prsn has joined #ocaml
<Matt____> Hi folks, new to ocaml. I have a question regarding match statements
<Matt____> I'm trying to write a function to square all items of a list and return the sum. Am I on the right track here?
<Matt____> let rec square_list x = match x with
<Guest32856> Is there any particular reason why ocamlnet uses objects so much?
<Matt____> | [] -> 0 | h :: t -> let g = h * h in square_list x;;
<Matt____> Small error in the typing there. I meant to write square_list t
<ggole> Matt____: you've probably used the wrong variable at the end there
<Matt____> It's a small excerise I've decided to try and do to get my head around ocaml a little ;)
<ggole> And you calculate g, but don't make use of it
<Matt____> that's right, and I'm unsure how
<ggole> You probably want to either cons it on the front or add it to an accumulator
<ggole> Depending on whether you want to generate the list of squares or ot
<ggole> *not
<mrvn> Matt____: let g = ... in ...
reem has joined #ocaml
<mrvn> Matt____: the g should appear in the second ...
<Matt____> let g = h * h in g square_list t
<Matt____> is something I'm going for
<mrvn> Matt____: what's [] squared? Certainly not 0
<Matt____> True, but I figured 0 would infer that I want an int returned
<mrvn> but you want a listr or not?
<mrvn> -r
<mrvn> oh wait, you want the sum of the squares. Ok. then [] -> 0 is correct.
<CissWit> Matt____: in g + square_list x;;
paradoja has quit [Ping timeout: 245 seconds]
<Matt____> if I have a list of [4 ; 4 ; 4] then I want to return the sum of all
<Matt____> sum of all squared*
<ggole> g + square_list t, I think
<mrvn> then it's only missing the "g + "
<CissWit> yes sorry
<Matt____> oh wow
<Matt____> it was as simple as that. Thanks a lot pal
<mrvn> Matt____: now you can make it tail recursive so it can also sum up large lists. And you could just use List.fold_left
<Matt____> That does make sense
<mrvn> but yeah, it is as simple as that
<Matt____> Thanks for the help folks
reem has quit [Ping timeout: 255 seconds]
rgrinberg has joined #ocaml
<mrvn> # let sqsum = List.fold_left (fun acc x -> acc + x * x) 0;;
<mrvn> val sqsum : int list -> int = <fun>
<Matt____> Interesting, let me try that out
<Matt____> Works a treat, and it makes much more sense
<Guest32856> Is ocamlnet the way to send an email right now, does cohttp provide anything ?
ebzzry has joined #ocaml
prsn has quit [Ping timeout: 272 seconds]
rgrinberg has quit [Ping timeout: 246 seconds]
prsn has joined #ocaml
mattrepl has joined #ocaml
mattrepl has left #ocaml [#ocaml]
mattrepl_ has joined #ocaml
mattrepl_ is now known as mattrepl
flux has quit [Ping timeout: 256 seconds]
martintrojer has joined #ocaml
flux has joined #ocaml
struktured has quit [Ping timeout: 256 seconds]
prsn has quit [Ping timeout: 252 seconds]
ptc has joined #ocaml
ptc is now known as Guest92314
prsn has joined #ocaml
thomasga has quit [Quit: Leaving.]
struktured has joined #ocaml
rgrinberg has joined #ocaml
rgrinberg has quit [Ping timeout: 264 seconds]
prsn has quit [Ping timeout: 255 seconds]
madroach_ has joined #ocaml
prsn has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
darkf has quit [Quit: Leaving]
ghostpl_ has joined #ocaml
rjcode has joined #ocaml
ghostpl_ has quit [Ping timeout: 240 seconds]
Matt____ has quit [Quit: Page closed]
prsn has quit [Ping timeout: 256 seconds]
prsn has joined #ocaml
kakadu has quit [Ping timeout: 246 seconds]
larhat has joined #ocaml
h0ffline has quit [Read error: Connection reset by peer]
rgrinberg has joined #ocaml
freling has quit [Quit: Leaving.]
prsn has quit [Ping timeout: 252 seconds]
prsn has joined #ocaml
kakadu has joined #ocaml
beginner has quit [Ping timeout: 256 seconds]
beginner has joined #ocaml
c74d has quit [Remote host closed the connection]
AlexRussia has quit [Ping timeout: 252 seconds]
c74d has joined #ocaml
c74d has quit [Remote host closed the connection]
prsn has quit [Ping timeout: 252 seconds]
prsn has joined #ocaml
c74d has joined #ocaml
AlexRussia has joined #ocaml
Guest32856 has left #ocaml ["ERC (IRC client for Emacs 25.0.50.1)"]
Algebr has joined #ocaml
* Algebr
prsn has quit [Ping timeout: 246 seconds]
prsn has joined #ocaml
<haesbaert> hmm how do I make a function that takes a fmt ?
<haesbaert> let vprintf env fmt = if env.verbose then
<haesbaert> Lwt_io.eprintf fmt
<haesbaert> else
<haesbaert> Lwt.return ()
<haesbaert> this doesn't seem to work
<Drup> use kprintf
<haesbaert> lemetry
<whitequark> but... lwt_io doesn't have one
<Drup> that's unfortunate, that could be added though.
<haesbaert> I tried this as well:
<haesbaert> let vprintf env fmt = if env.verbose then Printf.ksprintf Lwt_io.eprint fmt
<Drup> no, that's not how it works :p
<haesbaert> yeah, was a desperate attempt
rjcode has left #ocaml ["ERC Version 5.3 (IRC client for Emacs)"]
<haesbaert> what I don't get is this, Lwt_io.eprintf is defined as:
<haesbaert> let eprintf fmt = Printf.ksprintf eprint fmt
<haesbaert> let eprint txt = write stderr txt
<Drup> read the documentation about Printf and try without Lwt_io at first
<haesbaert> ack
rgrinberg has quit [Ping timeout: 256 seconds]
Haudegen has quit [Ping timeout: 272 seconds]
Guest92314 has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
matason has joined #ocaml
prsn has quit [Ping timeout: 250 seconds]
prsn has joined #ocaml
<jprakash> Would somebody please explain why I'm getting this error, and how I might fix it? https://gist.github.com/moonlightdrive/2fcb33f26b72bbe6197d
Haudegen has joined #ocaml
dav has joined #ocaml
<Drup> " type _ sexp = Sexp_atom : 'a atom -> 'b atom sexp "
<Drup> I'm pretty sure you want "Sexp_atom : 'a atom -> 'a atom sexp "
<Drup> the issue here is that, with this definition, given a "Sexp_atom foo" you have no idea what the type of foo is
<Drup> (that's what the error message is saying, the type of foo is not known, hence you can't return it to the external word)
<jprakash> hmm but I want to make lists like [Sexp_atom (Abool true); Sexp_atom (Aint 3)] and couldn't do that with 'a atom -> 'a atom sexp
<Drup> I see, you want an heterogeneous list.
<Drup> 1) don't put an unbound variable then, just do "type sexp = Sexp_value : 'a atom -> sexp"
<haesbaert> Drup: I still don't get it, ksprintf wants a function that takes a string, and a format, it then formats the string and applies the function to it
<Drup> 2) You just discovered existential types, all my condolences :D
<haesbaert> I'd then, expect this to work: let myprintf p fmt = if p then ksprintf print fmt else ()
<haesbaert> I'm trying to get it without Lwt as you suggested
myst|work has quit [Ping timeout: 256 seconds]
<whitequark> haesbaert: ksprintf is basically continuation passing style printf
<Drup> do you know what the *s* is for in ksprintf ?
<whitequark> sprintf*
<haesbaert> whitequark: continuation passing style being ?
<haesbaert> Drup: I guess string
<haesbaert> as the doco says it is "the same as sprintf"
<Drup> not really, it's explained in printf I think
<whitequark> oh. well then it's not an explanation that's going to help you
<Drup> err
<haesbaert> seriously I'm finding the documentation beyond horrible
<Drup> how fuck, I'm sorry, I meant ifprintf, not k >_>
<haesbaert> in my case ikfprintf I assume ?
<Drup> so basically, the goal is to use the normal variation if verbose is on and the *i* version if verbose if off
<haesbaert> ohhhhh
<Drup> kprintf is the father of all the printfs, all the other are implemented with it
shinnya has quit [Ping timeout: 256 seconds]
<Drup> (hence you can implement all the i versions with ikprintf)
<Drup> ikf*
<jprakash> Drup: still getting the same error
<Drup> jprakash: sure, that's normal, you are still trying to do something untyped.
ghostpl_ has joined #ocaml
<haesbaert> Drup: ack now I got it.
<haesbaert> but seriously, is there a policy of not putting any kind of examples in the manual, or of giving small, almost cryptic explanations of it ?
<Drup> I prefer not to answer that :<
myst|work has joined #ocaml
<haesbaert> or is it just the fact that I'm a beginner, cause seriously it seems to be designed to make new users walk away sometimes.
<Drup> no, you are absolutely right.
<haesbaert> ack, nice to know I'm not insane \o/
prsn has quit [Ping timeout: 245 seconds]
<Drup> jprakash: so, the issue is that what you are trying to do will not work as it.
MercurialAlchemi has quit [Ping timeout: 244 seconds]
MercurialAlchemi has joined #ocaml
<jprakash> because foo in Sexp_atom foo could be anything?
<Drup> once you put something in the existential (that's your sexp type), you "forget" the type information, and you can't get them back. This means that you can open the existential box, you can play with it, but you can't return it or use it's specific type.
psy_ has quit [Ping timeout: 244 seconds]
<Drup> it would be in 'a atom, yes
<Drup> could*
prsn has joined #ocaml
<Drup> any*
c74d has quit [Remote host closed the connection]
dsheets has quit [Quit: Leaving]
<jprakash> how/why do you use existential types if you can't get what you put into it out
<Drup> it doesn't mean you can't do what you want, just not this way.
<Drup> well, it's occasionally very useful.
<Drup> you can get what you put into it. You just can't return it.
dsheets has joined #ocaml
tg has quit [Ping timeout: 244 seconds]
<Drup> imagine you have a print_atom function
<Drup> you can perfectly do "let print_of_sexp (Sexp_atom a) = print_atom a"
<Drup> because it doesn't return the type of a.
ghostpl_ has quit [Ping timeout: 272 seconds]
<jprakash> I see
thomasga has joined #ocaml
_5kg has quit [Ping timeout: 246 seconds]
c74d has joined #ocaml
psy_ has joined #ocaml
<Drup> Of course, if you actually pattern match foo, you will know the type.
mort___ has joined #ocaml
psy_ has quit [Max SendQ exceeded]
psy_ has joined #ocaml
psy_ has quit [Max SendQ exceeded]
paradoja has joined #ocaml
TheLemonMan has quit [Quit: leaving]
<jprakash> I don't understand why I can do (Sexp_value (Abool b)) -> string_of_bool b
<jprakash> but not (Sexp_value (Abool b)) -> Bool b
tg has joined #ocaml
<jprakash> I mean, both string_of_bool and Bool require that type information about b that was "forgotten", right?
matason has quit [Ping timeout: 265 seconds]
<Drup> what's the error with the second ?
rgrinberg has joined #ocaml
<jprakash> oh sorry I can do that. But I can't do it with (Sexp_value (Aint i)) -> Int i also in the function
beginner has quit [Ping timeout: 252 seconds]
<Drup> yes
<Drup> that's because you fix the output type (by saying it's a bool)
<jprakash> yes
<jprakash> how do I avoid that
beginner has joined #ocaml
beginner has joined #ocaml
<jprakash> can I?
<Drup> not if you want to put all the elements in the same list.
<Drup> you have to choose, you can't do both :)
dav has quit [Quit: leaving]
<jprakash> :(
prsn has quit [Ping timeout: 240 seconds]
<Drup> (well, you can add more layers, of course)
prsn has joined #ocaml
paradoja has quit [Ping timeout: 265 seconds]
paradoja has joined #ocaml
maurer has quit [Remote host closed the connection]
maurer has joined #ocaml
<dmbaturin> I still find socket multiplexing with Lwt puzzling. What is the correct way to do it?
<dmbaturin> Lwt.async returns unit rather than Lwt.t, so I can't use bind with Lwt_unix.accept in it.
<Drup> I'm not sure to see your issue
<dmbaturin> Drup: Well, I want to accept connections and keep reading from them and handling received data. As I understand, using Lwt.async with a callback parameterized by file descriptor would do what I want, right?
prsn has quit [Ping timeout: 250 seconds]
<Drup> not really
<Drup> well, actually, it depends what you want to do with the connections when they end
<Drup> if you don't care, Lwt.async is fine
prsn has joined #ocaml
<Drup> if you do care, you need to keep the thread around and use something like choose or join.
<dmbaturin> Where can I see how people are doing it?
<Drup> hum, not sure I have a nice code example at hand
slash^ has quit [Read error: Connection reset by peer]
_5kg has joined #ocaml
mort___ has quit [Quit: Leaving.]
reem has joined #ocaml
ghostpl_ has joined #ocaml
prsn has quit [Ping timeout: 250 seconds]
prsn has joined #ocaml
ghostpl_ has quit [Ping timeout: 264 seconds]
prsn has quit [Ping timeout: 252 seconds]
prsn has joined #ocaml
kakadu_ has joined #ocaml
kakadu has quit []
The_Mad_Pirate has quit [Ping timeout: 240 seconds]
prsn has quit [Ping timeout: 245 seconds]
The_Mad_Pirate has joined #ocaml
prsn has joined #ocaml
paradoja has quit [Ping timeout: 252 seconds]
govg has joined #ocaml
paradoja has joined #ocaml
prsn has quit [Ping timeout: 252 seconds]
prsn has joined #ocaml
ghostpl_ has joined #ocaml
c355E3B has joined #ocaml
oriba has joined #ocaml
ghostpl_ has quit [Ping timeout: 246 seconds]
shinnya has joined #ocaml
jprakash has quit [Quit: leaving]
thomasga has quit [Quit: Leaving.]
prsn has quit [Ping timeout: 250 seconds]
prsn has joined #ocaml
matason has joined #ocaml
prsn has quit [Ping timeout: 245 seconds]
ggole has quit []
prsn has joined #ocaml
c74d has quit [Read error: Connection reset by peer]
Drup has quit [Quit: Tatayoyo]
reem has quit [Remote host closed the connection]
c74d has joined #ocaml
Nahra has quit [Remote host closed the connection]
Drup has joined #ocaml
reem has joined #ocaml
mort___ has joined #ocaml
rgrinberg has quit [Ping timeout: 244 seconds]
Submarine has quit [Quit: Leaving]
rgrinberg has joined #ocaml
michael_lee has joined #ocaml
prsn has quit [Ping timeout: 265 seconds]
psy_ has joined #ocaml
prsn has joined #ocaml
swgillespie has joined #ocaml
michael_lee has quit [Quit: Ex-Chat]
bjorkintosh has quit [Ping timeout: 246 seconds]
reem has quit [Remote host closed the connection]
bjorkintosh has joined #ocaml
prsn has quit [Ping timeout: 252 seconds]
prsn has joined #ocaml
bjorkintosh has quit [Ping timeout: 255 seconds]
psy_ has quit [Ping timeout: 252 seconds]
mort___ has quit [Quit: Leaving.]
bjorkintosh has joined #ocaml
prsn has quit [Ping timeout: 245 seconds]
prsn has joined #ocaml
<whitequark> hey companion_cube
psy_ has joined #ocaml
bjorkintosh has quit [Ping timeout: 244 seconds]
bjorkintosh has joined #ocaml
kakadu_ has quit [Read error: Connection reset by peer]
ghostpl_ has joined #ocaml
reem has joined #ocaml
ghostpl_ has quit [Ping timeout: 265 seconds]
prsn has quit [Ping timeout: 245 seconds]
yminsky has joined #ocaml
prsn has joined #ocaml
bjorkintosh has quit [Ping timeout: 246 seconds]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
swgillespie has joined #ocaml
yminsky has quit [Quit: yminsky]
jprakash has joined #ocaml
prsn has quit [Ping timeout: 256 seconds]
prsn has joined #ocaml
yminsky has joined #ocaml
bjorkintosh has joined #ocaml
matason has quit [Ping timeout: 265 seconds]
<adrien> how can you name anything "yolo"? ='(
<dmbaturin> adrien: First you schedule a meeting with marketing people...
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<adrien> :)
swgillespie has joined #ocaml
xificurC has quit [Ping timeout: 256 seconds]
yminsky has quit [Quit: yminsky]
Algebr has quit [Read error: Connection reset by peer]
badkins has quit [Read error: Connection reset by peer]
Algebr has joined #ocaml
badkins has joined #ocaml
prsn has quit [Ping timeout: 264 seconds]
meteo has quit [Ping timeout: 245 seconds]
Snark has quit [Ping timeout: 240 seconds]
beginner has quit [Ping timeout: 272 seconds]
prsn has joined #ocaml
beginner has joined #ocaml
meteo has joined #ocaml
Snark has joined #ocaml
prsn has quit [Ping timeout: 252 seconds]
prsn has joined #ocaml
nullcat has joined #ocaml
SGrondin has joined #ocaml
tane has quit [Quit: Verlassend]
cartwright is now known as oxford
dhil has joined #ocaml
prsn has quit [Ping timeout: 264 seconds]
tnguyen has quit [Quit: tnguyen]
prsn has joined #ocaml
cdidd has quit [Ping timeout: 246 seconds]
cdidd has joined #ocaml
oxford is now known as cartwright
prsn has quit [Ping timeout: 240 seconds]
swgillespie has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
prsn has joined #ocaml
ghostpl_ has joined #ocaml
ghostpl_ has quit [Ping timeout: 240 seconds]
prsn has quit [Ping timeout: 255 seconds]
prsn has joined #ocaml
nullcat has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
sdothum has quit [Ping timeout: 246 seconds]
Simn has quit [Quit: Leaving]
<SGrondin> Lwt_preemptive + ctypes = a lot of fun
c355E3B has quit [Quit: Leaving]
prsn has quit [Ping timeout: 252 seconds]
<SGrondin> Parallel (not just concurrent) C calls, all that managed with Lwt in the OCaml code
prsn has joined #ocaml
psy_ has quit [Ping timeout: 264 seconds]