<mfp>
flux, thelema: patches against old Batteries that (1) add capabilities to IO streams using phantom types (2) (line 3339) creates seekable streams when opening files http://ocaml.pastebin.com/z0rEfXTD
<flux>
now I wonder how I perform the seek in general :)
<brendan>
huh. ocaml not build with 64-bit off_t?
<brendan>
seems strange though
<flux>
it is
<thelema>
can you try two smaller seeks that add up to that?
<flux>
actually I may have some other issue, I'll do it in another way
<thelema>
mfp: ah, you need the phantom types for keeping track of `seek
<flux>
nope, the conversion from the 64-bit hex string into an integer seems to work fine as well
tmaedaZ has quit [Ping timeout: 258 seconds]
<thelema>
any chance of merging input/output - `Read channel / `Write channel?
ikaros has quit [Quit: Leave the magic to Houdini]
tmaedaZ has joined #ocaml
f[x] has quit [Ping timeout: 240 seconds]
ftrvxmtrx has quit [Quit: Leaving]
krankkatze has joined #ocaml
tmaedaZ has quit [Ping timeout: 246 seconds]
tmaedaZ has joined #ocaml
_unK has quit [Remote host closed the connection]
ikaros has joined #ocaml
itewsh has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
<flux>
hmh, again I'd like to have a consume-as-needed variant of bitstring.. but perhaps not enough to actually do it :)
slash_ has joined #ocaml
barismetin has quit [Quit: Leaving...]
itewsh has quit [Quit: There are only 10 kinds of people: those who understand binary and those who don't]
ulfdoz has joined #ocaml
munga has quit [Ping timeout: 248 seconds]
slash_ has quit [Quit: leaving]
Yoric has quit [Quit: Yoric]
ttamttam has joined #ocaml
SEcki has joined #ocaml
rwmjones has quit [Ping timeout: 260 seconds]
<kaustuv>
OUnit users: do you write your tests inline with your modules or in separate modules? And, if you don't or can't use Camlp4, how do you disable compilation of tests?
ttamttam has quit [Read error: Connection reset by peer]
<derdon>
kaustuv: I don't use OUnit yet, but I strongly recommend using seperate files for the tests!
<derdon>
kaustuv: you have for example a module called foo.ml and foo.mli. then you have an extra directory for the tests called tests
<derdon>
kaustuv: in the tests directory is a file called test_foo.ml
<derdon>
kaustuv: this file uses the modules OUnit and Foo (and maybe some others too)
rwmjones has joined #ocaml
Associat0r has joined #ocaml
joewilliams_away is now known as joewilliams
nejimban has joined #ocaml
ttamttam has joined #ocaml
joewilliams is now known as joewilliams_away
<kaustuv>
derdon: I'm not worried about the how, but about the why. What are the arguments in favour of keeping tests separate and why do they supercede the obvious benefits of keeping the tests close to the code they're testing?
<derdon>
kaustuv: it is cleaner and much better style to seperate these tasks
<derdon>
kaustuv: imagine you change the API of your code. if your tests are well-written, you don't have to rewrite them because only input and output are important
ftrvxmtrx has joined #ocaml
<flux>
wouldn't simple unit tests also serve as examples on how to use the interface?
<derdon>
flux: no, that's not their aim
<mrvn>
If the tests still work after a change then you didn't (fundamentally) change the API.
<mrvn>
And if you change the API other than extending it then you deserve to be shot anyway. :)
<derdon>
mrvn: maybe I did some bad things and see that I have to change some part of a function
<flux>
pft, interfaces can always get better ;)
<flux>
too bad there is no way to describe the changes in a way that is automatically processible
<derdon>
mrvn: unittests feed a function with some values and test its return value
<derdon>
mrvn: they cannot test what happends "behind the scenes"
<derdon>
*happens
<mrvn>
And what else is an API? The API doesn't care how the implementation does it. Just what input gives what result.
<mrvn>
flux: Then you extend it and carry along the old stuff with some compatibility layer.
<flux>
mrvn, and end up with a mega-interface
<derdon>
mrvn: API was the wrong word.
<mrvn>
flux: Yes. so think about the Interface befor declaring it stable.
<flux>
mrvn, how much success have you had with actually following doing things this way?
<mrvn>
flux: A lot but not always. Sometimes it is better to start from scratch.
<flux>
one of the nicest things about languages with static type systems is that you can infact change an interface and nothing will break silently. so you can do it.
<mrvn>
flux: and all the people using your interface will curse you
<flux>
simply don't upgrade ;)
<mrvn>
Does ocaml have any notion of SOVERSION or versioned symbols?
knorr has joined #ocaml
ulfdoz has quit [Remote host closed the connection]
knorr has left #ocaml []
menace has joined #ocaml
<mrvn>
flux: not upgrading isn't always an option. You might have sources that need the new one.
<kaustuv>
Sorry for the delayed response, but I often write modules that have very narrow APIs, often just a function or two, but I would still like to state and test the invariants used in its implementation. Separating the tests forces me to maintain a public and a private API, or selectively compile the .mli files, neither of which is effortless
<mrvn>
Upgrading seems to be one thing ocaml is verry bad at anyway. You always need to recompile everything when you upgrade ocaml itself for example.
<mrvn>
kaustuv: unit tests are supposed to use the public api
<kaustuv>
That's a pretty dogmatic statement about tests
<mrvn>
kaustuv: A big drawback of putting the tests next to the real code is binary size.
<mrvn>
kaustuv: No. that is how unit tests usualy work
<kaustuv>
Well, then, suppose I don't call my tests "unit tests" but rather "invariant checking tests". People surely write such things!
<derdon>
what are private APIs? APIs for closed source code?
<mrvn>
How do you put your tests next to the code in ocaml? Doesn't that mean all your test functions become part of the API?
<mrvn>
derdon: functions you don't list in the mli file
menace has left #ocaml []
ulfdoz has joined #ocaml
<derdon>
mrvn: I see
<kaustuv>
mrvn: well, obviously I don't include the functions used in test building in the interface. And if my tests are of the form:
<kaustuv>
let () = let module Test = struct ... end in (), then the interface isn't polluted anyhow
<mrvn>
kaustuv: so you put some form of #ifdef TEST around it?
<kaustuv>
That would be ideal and easily doable with Camlp4MacroProcessor, but for difficult to explain reasons I would rather not use Camlp4
<mrvn>
You must have some way to disable the tests or do you really want to test on every programm start?
<kaustuv>
That was my initial question. I have since then figured out how to use gcc -E for this, but it's a fairly ugly hack.
<mrvn>
ahh, didn't see your initial question, just dropped in in the middle.
<mrvn>
gcc -E + #ifdef works fine. Just means some customization of the Makefiles.
<kaustuv>
However, gcc -E puts #stuff in the file which I have to fiter out, and is a bit annoying about having #stuff appear at the starts of lines in the source. These are not huge problems (so far).
tmaedaZ has quit [Ping timeout: 268 seconds]
<derdon>
what is the best way of testing whether a string is empty? pattern matching not an option because the else part has a long try-with construct
tmaedaZ has joined #ocaml
<derdon>
I could test the length with ``if Str.length the_string = 0 then "empty string!" else "non-empty string!"``, but that looks like bad style to me
<kaustuv>
String.length is O(1) so there is practically no reason to avoid it
<mrvn>
let foo bar baz = function "" -> "empty" | s -> bar s baz
<mrvn>
if the string is the last arg
<derdon>
mrvn: and what is bar?
<mrvn>
some other arg
<derdon>
aha
<derdon>
I use String.length :D
<mrvn>
let foo = function "" -> "Empty | s -> fun bar baz -> bar s baz looks ugly imho but also works
<mrvn>
s/"Empty/fun _ _ -> "Empty"/
<mrvn>
I also like if Str.length the_string = 0 then raise Empty; <normal code>
<derdon>
good
<mrvn>
I prefer that to else because it indents less
_andre has quit [Quit: *puff*]
<derdon>
yes, me too
<derdon>
it depends a bit on the context
willb1 has quit [Ping timeout: 248 seconds]
ttamttam has quit [Quit: Leaving.]
<mrvn>
obviously if you can't raise an exception in the then part then ...
willb1 has joined #ocaml
willb1 has quit [Ping timeout: 258 seconds]
eldragon has quit [Read error: Connection reset by peer]
eldragon has joined #ocaml
<derdon>
mrvn: now I use pattern-matching
willb1 has joined #ocaml
<derdon>
mrvn: I wrote a seperate function for the else part
<mrvn>
works too
kaustuv has quit [Quit: ERC Version 5.3 (IRC client for Emacs)]
maskd has quit [Quit: leaving]
jimmyb2187 has left #ocaml []
linus5 has quit [Remote host closed the connection]
pimmhogeling has quit [Ping timeout: 265 seconds]
enthymeme has joined #ocaml
jeddhaberstro has joined #ocaml
<mrvn>
let todo = ref [ "Get package from post office" ];;
maattd has joined #ocaml
maskd has joined #ocaml
Submarine has quit [Read error: Operation timed out]
slash_ has joined #ocaml
det has joined #ocaml
ygrek has quit [Ping timeout: 245 seconds]
thrasibule has joined #ocaml
oc131 has quit [Ping timeout: 245 seconds]
thieusoai has quit [Remote host closed the connection]
ygrek has joined #ocaml
ulfdoz has quit [Ping timeout: 240 seconds]
<derdon>
can the module Str distinguish between greedy and non-greedy expressions?
maattd has quit [Remote host closed the connection]
<flux>
I don't think so
<flux>
I use PCRE almost always anyway
<flux>
Str's non-threadsafety (even in the parts that look safe) has bitten me into butt once :)
thrasibule has quit [Read error: Operation timed out]
thieusoai has joined #ocaml
<derdon>
flux: is PCRE possible when using the batteries?
<flux>
sure
<flux>
although I don't think batteries makes use of it
<flux>
but you afaik can use any other library with batteries
<derdon>
flux: what do you mean exactly by "I use PCRE almost always anyway" then?
<derdon>
is there an ocaml library called pcre or what?