mattam has quit [Read error: 110 (Connection timed out)]
Nutssh has joined #ocaml
Tachyon76 has quit ["Leaving"]
Riastrad1 has joined #ocaml
Riastradh has quit [Nick collision from services.]
Riastrad1 is now known as Riastradh
Nutssh has quit ["Client exiting"]
Nutssh has joined #ocaml
pattern has quit [Connection timed out]
pattern has joined #ocaml
det has joined #ocaml
mimosa has quit ["J'ai fini."]
gim has quit ["Zzz."]
kinners has joined #ocaml
mattam_ is now known as mattam
Nutssh has quit [Read error: 60 (Operation timed out)]
Nutssh has joined #ocaml
kinners has quit ["leaving"]
wazze has joined #ocaml
lus|wazze has joined #ocaml
lus|wazze has quit [Client Quit]
Nutssh has quit ["Client exiting"]
yeoh has joined #ocaml
det has quit [Read error: 104 (Connection reset by peer)]
Nutssh has joined #ocaml
Hipo has quit ["leaving"]
The-Fixer has quit ["Goodbye"]
Nutssh has quit ["Client exiting"]
yeoh has quit [orwell.freenode.net irc.freenode.net]
N407ER has quit [orwell.freenode.net irc.freenode.net]
Smerdyakov has quit [orwell.freenode.net irc.freenode.net]
cjohnson has quit [orwell.freenode.net irc.freenode.net]
N407ER has joined #ocaml
cjohnson has joined #ocaml
Smerdyakov has joined #ocaml
LordJ|m has quit [Connection timed out]
Demitar_ has joined #ocaml
mimosa has joined #ocaml
Smerdyakov has quit [orwell.freenode.net irc.freenode.net]
andrewb has quit [orwell.freenode.net irc.freenode.net]
andrewb has joined #ocaml
Smerdyakov has joined #ocaml
andrewb has quit [orwell.freenode.net irc.freenode.net]
Smerdyakov has quit [orwell.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
andrewb has joined #ocaml
whiskas has joined #ocaml
Smerdyakov has quit [orwell.freenode.net irc.freenode.net]
andrewb has quit [orwell.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
andrewb has joined #ocaml
Smerdyakov has quit [orwell.freenode.net irc.freenode.net]
andrewb has quit [orwell.freenode.net irc.freenode.net]
smkl has quit [orwell.freenode.net irc.freenode.net]
Godeke has quit [orwell.freenode.net irc.freenode.net]
shawn has quit [orwell.freenode.net irc.freenode.net]
N407ER has quit [orwell.freenode.net irc.freenode.net]
yella has quit [orwell.freenode.net irc.freenode.net]
lam has quit [orwell.freenode.net irc.freenode.net]
andrewb has joined #ocaml
Smerdyakov has joined #ocaml
N407ER has joined #ocaml
Godeke has joined #ocaml
smkl has joined #ocaml
lam has joined #ocaml
shawn has joined #ocaml
yella has joined #ocaml
Demitar_ has quit [Read error: 60 (Operation timed out)]
gim has joined #ocaml
Smerdyakov has quit [orwell.freenode.net irc.freenode.net]
andrewb has quit [orwell.freenode.net irc.freenode.net]
Smerdyakov has joined #ocaml
andrewb has joined #ocaml
LordJ|m has joined #ocaml
Jondice has quit [Client Quit]
slashvar[lri] is now known as slashvar[TD]
<drWorm>
isn't there some function that gives the position of a substring in a string, or for instance -1 if it doesn't exist? the String module only has for chars.
<drWorm>
module ExtString.String in extlib (ocaml-lib.sf.net) has it, i'll use that
whiskas has quit ["Pa / Bye."]
Lemmih has quit [Remote closed the connection]
bk_ has joined #ocaml
phj has joined #ocaml
Tachyon76 has joined #ocaml
mellum has quit [Remote closed the connection]
The-Fixer has joined #ocaml
cjohnson has quit ["Drawn beyond the lines of reason"]
Lemmih has joined #ocaml
Tachyon76 has quit ["Leaving"]
slashvar[TD] is now known as slashvar[lri]
Demitar has quit [orwell.freenode.net irc.freenode.net]
Demitar has joined #ocaml
demitar_ has joined #ocaml
Demitar has quit [Read error: 104 (Connection reset by peer)]
Nutssh has joined #ocaml
Nutssh has quit ["Client exiting"]
maihem has joined #ocaml
mellum has joined #ocaml
<mellum>
Hm, why do I get a type error for this:
<mellum>
type something = int;;
<mellum>
let print_something channel i = Printf.fprintf channel "*%d*" i;;
<mellum>
let string_of_something i = Printf.sprintf "%a" print_something window;;
<Smerdyakov>
Well, the second 'i' is unused. Is that purposeful?
<mellum>
Uhm. I meant "i" instead of "window"
<Smerdyakov>
Did that fix it?
<mellum>
no
<mellum>
This expression has type out_channel -> int -> unit
<mellum>
but is here used with type unit -> 'a -> string
det has joined #ocaml
<mellum>
Why is the use "unit -> 'a -> string"? I don't understand it
fjb has joined #ocaml
<slashvar[lri]>
mellum: this the type for witch function ?
<det>
slashvar[lri]: interesting! what does a witch function do?
<slashvar[lri]>
sorry ...
<slashvar[lri]>
which
<mellum>
slashvar[lri]: string_of_something
<mellum>
the error is about the expression part "print_something"
<mellum>
it works with printf, but not sprintf...
<Smerdyakov>
I'm not very familiar with how format string magic works in OCaml.
<Smerdyakov>
Did you check what OCaml thinks the type of print_something is?
<mellum>
me neither. I always hit its limitations
<mellum>
Smerdyakov: as I pasted, it is out_channel -> int -> unit, but ocaml thinks in string_of_something it should be unit -> 'a -> string
<Smerdyakov>
Oh, yeah.
<Smerdyakov>
Add an extra () arg to and make it return a string.
<mellum>
to what?
<mellum>
if you mean to print_something, I can't modify it, it's a black box
phj has quit [Read error: 104 (Connection reset by peer)]
<slashvar[lri]>
it does the same things with ouput_string instead of print_something
<Smerdyakov>
I think %a is expecting string-generators, not channel-writers.
<Smerdyakov>
Which seems wrong :\
<slashvar[lri]>
hum ... if you do :
<slashvar[lri]>
let string_of_something = Printf.sprintf "%a" (fun c i -> print_something c i) i ;;
<slashvar[lri]>
it says about c : This expression has type unit but is here used with type out_channel
<slashvar[lri]>
so, he call print_something with () as first argument ...
<slashvar[lri]>
'b is the type of the first argument given to %a and %t printing functions.
<slashvar[lri]>
(from the documentation, so as sprintf have unit for 'b, this why it doesn't work)
cjohnson has joined #ocaml
<slashvar[lri]>
it seems that you can't what you want that way
<slashvar[lri]>
mellum: in fact, your doing things in the wrong, since, it's far better to have a to_string function, and then, out of that function build a to_out_channel function
<slashvar[lri]>
+way
Pelikan has joined #ocaml
wazze has quit ["--- reality is that which, when you stop believing in it, doesn't go away ---"]
Pelikan has quit [Read error: 104 (Connection reset by peer)]
<malte>
hm, what is the good thing with having a static type system?
<mellum>
More things are checked at compile time. And it's more efficient.
fjb has quit [Remote closed the connection]
slashvar[lri] has quit [Read error: 60 (Operation timed out)]
slashvar[lri] has joined #ocaml
mimosa has quit [Read error: 113 (No route to host)]
<malte>
mellum, efficient for the programmer?
gim has quit [Read error: 113 (No route to host)]
<mellum>
malte: I meant execution. Efficient for the programmer is hard to quantify
<mellum>
Sometimes, the type system is in your way and you could write things faster without it. However, it forces you to think about design more clearly, which might lead to less maintainance later
<malte>
ok, thanks mellum :)
CosmicRay has joined #ocaml
* CosmicRay
is trying to figure out how to round a float to a particular number of digits... all I can find are floor and ceil, which are not what I want
<CosmicRay>
suggestions?
<mellum>
let round_up n x =
<mellum>
let p = 10. ** (float_of_int n) in
<mellum>
(ceil (p *. x)) /. p;;
<mellum>
well, that one always rounds up, but you probably get the idea
<CosmicRay>
yeah...
<mellum>
Or just use printf
<CosmicRay>
well my requirements are fairly rigid with respect to string output
<CosmicRay>
I already have some sophisticated logic there...
<CosmicRay>
I suppoese I could float_of_string the result of sprintf
<CosmicRay>
but that just seems so wrong :-)
<mellum>
doesn't seem that unreasonable to me
CosmicRay has quit ["Client exiting"]
Nutssh has joined #ocaml
skylan has quit [""It takes many nails to build crib, but one screw to fill it.""]