w0rm_x has quit [Quit: if Φ Σ e : φ then Φ Σ τ' → σ' :: ∃]
ollehar has joined #ocaml
Drup has quit [Ping timeout: 240 seconds]
Drup has joined #ocaml
manud_ has joined #ocaml
manud_ has quit [Ping timeout: 272 seconds]
ggole has joined #ocaml
<ggole>
Is there a way to create an out_channel such that printing to it contributes to the contents of a string (or Buffer.t)?
Drup has quit [Ping timeout: 268 seconds]
ollehar has quit [Ping timeout: 246 seconds]
gour has joined #ocaml
<ggole>
Seems not. :(
<ggole>
However, I could change my code to collect the text in a Buffer.t, and then I'll have the choice of outputting or stringifying it
<ggole>
Any opinions on whether that's a reasonable path forward?
<whitequark>
ggole: personally, I'd do either that or abstract over a channel or a buffer
<whitequark>
(basically, C++ ostream... :)
<ggole>
There's such an abstraction for lexing, but not output
<whitequark>
yeah, I'm surprised there isn't
<ggole>
I'll just use a Buffer.
<ggole>
Thankfully bprintf is a thing.
Drup has joined #ocaml
manud_ has joined #ocaml
manud_ has quit [Ping timeout: 272 seconds]
manud_ has joined #ocaml
madroach has quit [Quit: leaving]
madroach has joined #ocaml
<adrien>
morning
Simn has joined #ocaml
manud_ has quit [Quit: Leaving]
skchrko has joined #ocaml
<ggole>
Tedious refactoring finished :/
strmpnk has quit [Ping timeout: 272 seconds]
strmpnk has joined #ocaml
Neros has joined #ocaml
Kakadu has joined #ocaml
shinnya has quit [Ping timeout: 248 seconds]
fantasticsid has joined #ocaml
fantasticsid has quit [Client Quit]
bnoordhuis has joined #ocaml
madroach has quit [Ping timeout: 264 seconds]
ontologiae has joined #ocaml
Drup has quit [Remote host closed the connection]
wolfnn has joined #ocaml
ulfdoz has joined #ocaml
ontologiae has quit [Ping timeout: 252 seconds]
<pippijn>
morning
<pippijn>
ggole: I'd use buffer
<ggole>
I did
<ggole>
It is quite ugly, but works ok
tobiasBora has joined #ocaml
<ggole>
It's annoying that the additional, useless layer of buffering is there
<ggole>
But it doesn't really matter much.
<Kakadu>
flux: how your ocsigen + ocamlbuild is going?
iZsh has quit [Ping timeout: 245 seconds]
darkf has quit [Quit: Leaving]
q66 has joined #ocaml
szacun has joined #ocaml
<szacun>
Hi! I am writing function to add a number to appropriate list depending whether the number is odd or even. I try do it with as few characters as possible and i would like to ask if there is a way to do it like this: http://pastebin.com/LLxTwc6M and maybe i have only some syntax error, or if this has completly no sense
<szacun>
actually i wrote this code to only show idea how i want to resolve a problem of choosing a list to add an element, i know that adding to list basing on parity may be done easier, but if there would be more lists and more complicated predicate it would require more if's
<companion_cube>
ggole: I had the same concern, now I have wrapped sprintf/printf/fprintf to use Buffer.t everwhere, and all my printing functions take a Buffer.t
gour has quit [Disconnected by services]
<companion_cube>
this way I can use the same code to output to a channel or to a string
gour_ has joined #ocaml
gour_ is now known as gour
<gasche>
szacun:
<gasche>
let test n (evens,odds) = let (e,o) = if n mod 2 = 0 then [n],[] else [],[n] in (e@evens,o@odds);;
<gasche>
if you allow to change the type, you may also use
<gasche>
let test n lists = let i = n mod 2 in lists.(i) <- n::lists.(i);;
<gasche>
(removing the "let i" binding is even faster)
<gasche>
s/faster/shorter/
bnoordhuis has quit [Ping timeout: 245 seconds]
<ggole>
companion_cube: hmm, why would you need to wrap printf and fprintf?
<companion_cube>
ggole: so that I can use printf "foo %a %a" pp1 x1 pp2 x2
<companion_cube>
even though pp1 and pp2 print into buffers
<ggole>
Ah
<companion_cube>
to be more precise, I can use printf, fprintf and sprintf with the same type printers
<ggole>
Hmm, doesn't bprintf already do taht?
<companion_cube>
of course, but it's more convenient to have shortcuts to print on stdout, out_channels and strings
<ggole>
I see.
<companion_cube>
that's why I said I "wrapped" them
<ggole>
Right, makes sense now.
<companion_cube>
they are basically kbprintf
<companion_cube>
+ a callback that outputs a string/prints it
* adrien
simple does "let sp = Printf.sprintf" or "let ep = Printf.eprintf"
<companion_cube>
adrien: this is not the problem, the problem is to write only one function for all the "%a" of one type
<gasche>
def-lkb: I just tried Melpa, which is cool (yeah, I don't often do sysadminy-things)
<gasche>
Merlin should be in the standard Melpa repository
<gasche>
(they can use git repos as packages, it seems)
<gasche>
(Melpa is a package manager for Emacs)
<gasche>
(included in Emacs 24)
<def-lkb>
gasche: you mean… distributing emacs mode separately from merlin ?
<rks`>
gasche: no it shouldn't
<rks`>
you wan't the emacs mode synchronized with the binary
<rks`>
(so they speak the same protocol)
<rks`>
you can't enforce that with the package system of emacs
<rks`>
(nor with vundle)
<rks`>
(want* btw)
strobegen has quit [Quit: Leaving.]
peterbb has quit [Ping timeout: 272 seconds]
zxqdms has quit [Quit: leaving]
Neros has quit [Ping timeout: 240 seconds]
bnoordhuis has joined #ocaml
bnoordhuis has quit [Ping timeout: 272 seconds]
Kakadu has quit []
Snark has quit [Quit: leaving]
ontologiae has joined #ocaml
strobegen has joined #ocaml
skchrko has quit [Quit: Leaving]
Neros has joined #ocaml
strobegen has quit [Ping timeout: 245 seconds]
<rks`>
kerneis: ping github/merlin :)
strobegen has joined #ocaml
Neros has quit [Ping timeout: 245 seconds]
bnoordhuis has joined #ocaml
peterbb has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
ontologiae has quit [Ping timeout: 246 seconds]
zpe has quit [Ping timeout: 260 seconds]
shinnya has joined #ocaml
bnoordhuis has quit [Ping timeout: 272 seconds]
ollehar has joined #ocaml
bnoordhuis has joined #ocaml
Neros has joined #ocaml
Arsenik has joined #ocaml
Neros has quit [Ping timeout: 245 seconds]
Neros has joined #ocaml
q66 has quit [Ping timeout: 246 seconds]
cesar_ has joined #ocaml
cesar_ is now known as Guest62634
<bnoordhuis>
this is probably well known and i understand why it happens but (abs min_int) = min_int
<bnoordhuis>
is it reasonable to expect the runtime to raise an exception in that case?
mcclurmc has joined #ocaml
zpe has joined #ocaml
<bnoordhuis>
"Note that this may be negative if the argument is min_int." - okay, at least it's documented :)
q66 has joined #ocaml
zpe has quit [Ping timeout: 252 seconds]
bnoordhuis has quit [Quit: leaving]
tobiasBora has quit [Ping timeout: 245 seconds]
<ggole>
That's the expected behaviour of two's complement, really
Guest62634 has quit [Remote host closed the connection]
dsheets has joined #ocaml
strobegen has quit [Ping timeout: 246 seconds]
<whitequark>
integer overflow in division <3
talzeus has quit [Read error: Connection reset by peer]
talzeus has joined #ocaml
Neros has quit [Ping timeout: 245 seconds]
tobiasBora has joined #ocaml
<ggole>
Exception on div by zero is ok, but exception on min_int / -1 is annoying -_-
<ggole>
Although OCaml doesn't have that because of tagging
zpe has joined #ocaml
<whitequark>
I think that if you have two's complement, you gotta have it.
<whitequark>
no exceptions (slow), no wacky undefined behavior either.
ollehar has quit [Ping timeout: 272 seconds]
<ggole>
Gotta have what?
<ggole>
abs min_int = min_int?
<whitequark>
yeah, and so on.
<whitequark>
perhaps you would have a distinct smallint and bigint types, but leave two's complement as it is.
<ggole>
Well, min_int / -1 could just give the same result as -min_int or min_int - 1
<ggole>
(It's often a DoS bug because people forget to check for it.)
<whitequark>
um, it does ?
<whitequark>
give the same result as -min_int
<ggole>
In OCaml, because of tagging
<whitequark>
hm
<ggole>
SIGFPE in C
<whitequark>
no
<whitequark>
UB in C
<ggole>
Sure: but that's the usual effect
strobegen has joined #ocaml
<whitequark>
actually, I don't think so
strobegen has quit [Remote host closed the connection]
<ggole>
Although it probably varies over platforms
talzeus has quit [Remote host closed the connection]
<ggole>
Which is worse
<whitequark>
gcc gives me INT_MIN with -O0-O3
<ggole>
With constant operands?
<whitequark>
clang gives me SIGFPE on -O0 and garbage on -O3
<ggole>
Try passing them on the command line so it can't be folded
<whitequark>
neither of those even includes division
<whitequark>
clang -O0 translates it to hlt
<adrien>
:D
<whitequark>
actually
<adrien>
btw, are you build with -Wall -Wextra ?
<whitequark>
clang -O0 -S *does* emit udiv
<whitequark>
but clang -O0 -o foo *does not*
<whitequark>
what
<whitequark>
(wall wextra) no, would that matter?
<ggole>
Might get a warning
<whitequark>
well, I did get one when I wrote INT_MIN / -1 as a constexpr
<whitequark>
but, frontends of both don't fold expressions with variables, and backends of both can, but don't emit warnings
<whitequark>
(hlt/no idiv) sorry, misread the assembly. clang -O0 emits idiv in both cases.
<whitequark>
and gcc folds it to INT_MIN even at -O0
<ggole>
Gcc folds constants in the parser iirc
<whitequark>
well, that means it will fold less constants, since if it optimizes away a variable reference so it becomes constant, it's not available for folding anymore
<whitequark>
I believe it does that both in FE & BE
<gasche>
ollehar: did you get my object-syntax answer?
<pippijn>
5 is better than 256
<pippijn>
and much better than 2^21
<ollehar>
gasche: hm, on SO?
<gasche>
nope, here
<gasche>
I experimented with the syntax-extension you pointed out
<gasche>
the problem is fundamental: the lid->lid syntax used by the extension is ambiguous
szacun has quit [Quit: Lost terminal]
<gasche>
consider "match .. with ... when p->q"
<gasche>
you can trivially fix the code by using --> instead for the object syntax
<gasche>
(note that the extension will still assert false instead of printing an error in case of misuse, as it is implemented in a rather fragile way)
<adrien>
what is this extension btw?
<gasche>
something Fabrice wrote to use object-like syntax with module for ocaml-wxwidgets
<ollehar>
gasche: I see
<gasche>
(I don't think anyone should use such an extension, but ollehar was still interested)
<ollehar>
gasche: I'll give that a try
fraggle_ has joined #ocaml
<ollehar>
well, all Lua API calls use the lua state as first arg
<adrien>
gasche: huh, ok; do you have a link to it? (just curious, don't worry ;-) )
<adrien>
or is it simply "Module.func obj arg" which becomes "obj->func arg"?
<adrien>
thanks
<ollehar>
adrien: yes, that's it
<gasche>
yes, it is this, provided you used something like "module obj->Module in" before
fraggle_ has quit [Ping timeout: 252 seconds]
peterbb has joined #ocaml
<ollehar>
gasche: no way to instead of `assert false` tell camlp4 to use `usual syntax`. Or if I define new behaviour for a operator, must I redefine the old behaviour too?
Drup has joined #ocaml
<gasche>
there is no general backtracking facility, but some cleverness in describing the grammar may help a bit with the "when" conflict
<gasche>
however, I think this is ultimately going to break down to the fact that the grammar is now (locally) ambiguous in a really bad way
<gasche>
you should just avoid that
<gasche>
(if you read "foo->bar" after a "when", there is no finite amount of lookahead you can make to decide how to interpret the arrow)
fraggle_ has joined #ocaml
wmeyer has joined #ocaml
<wmeyer>
hello.
<whitequark>
wmeyer: hi!
<adrien>
o/
<wmeyer>
whitequark: hi.
<wmeyer>
adrien: :D \o
* adrien
leaving very soon but back to ocaml patches on tomorrow
<wmeyer>
chilling out =)
<wmeyer>
great
<wmeyer>
ping me
<whitequark>
btw
<whitequark>
windows cross compiling? :)
<wmeyer>
please, I will commit them
<wmeyer>
yes whitequark :-)
<whitequark>
neat!
<ollehar>
gasche: ok, thanks for taking your time :)
<eikke>
we had a design discussion some time ago at work, and at a certain point I knew how to solve something we hit against using (open) TFs, but I wouldnt know how to do it using ocaml
<mrvn>
cool. Now we only need open types for records too
<gasche>
I am hesitant to encourage people to use GADTs to represent type-level mappings, because conceptually I feel that is rather ugly
<gasche>
on the other hand, the way Haskell does type family is in fact just as "ugly"
<eikke>
well, it seems like the most obvious way to pass evidence?
<gasche>
yeah, but shouldn't we use proper F_omega-style type-level reduction?
<gasche>
GADTs (or type families) correspond to defining function set-theoretically by passing a set of (input, output) pairs
<gasche>
which is rather yucky
ggole has quit []
srcerer_ has joined #ocaml
Neros_ has joined #ocaml
srcerer has quit [Ping timeout: 268 seconds]
Neros has quit [Ping timeout: 260 seconds]
Neros_ has quit [Read error: Connection reset by peer]
bobzhang1988 has quit [Ping timeout: 245 seconds]
Kakadu has joined #ocaml
tane has joined #ocaml
eikke has quit [Ping timeout: 266 seconds]
darkf has joined #ocaml
gour has quit [Quit: WeeChat 0.4.1]
Anarchos has joined #ocaml
cthuluh has quit [Ping timeout: 248 seconds]
cthuluh has joined #ocaml
<Anarchos>
cthuluh je t'ai pas appelé...
zpe has joined #ocaml
wwilly has quit [Remote host closed the connection]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Read error: Connection reset by peer]
zpe has joined #ocaml
Arsenik has quit [Remote host closed the connection]
tobiasBora has joined #ocaml
mcclurmc has joined #ocaml
Neros has joined #ocaml
mcclurmc has quit [Quit: Leaving.]
peterbb has quit [Ping timeout: 272 seconds]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
zpe has quit [Ping timeout: 248 seconds]
<tobiasBora>
Hello,
Kakadu has quit [Quit: Konversation terminated!]
<tobiasBora>
I'd like to get my IP adresse on the local network, but when I do this :