rwmjones changed the topic of #ocaml to: Discussions about the OCaml programming language | http://caml.inria.fr/ | Grab Ocaml 3.10.2 from http://caml.inria.fr/ocaml/release.html (featuring new camlp4 and more!)
hkBst has quit ["Konversation terminated!"]
Anarchos has quit ["Vision[0.8.5-0418]: i've been blurred!"]
evn has quit []
jlouis_ has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
Tetsuo has quit ["Leaving"]
Mr_Awesome has quit [Read error: 110 (Connection timed out)]
Mr_Awesome has joined #ocaml
AxleLonghorn has left #ocaml []
seafood_ has joined #ocaml
middayc has joined #ocaml
benzo has joined #ocaml
a13x has joined #ocaml
benzo has quit []
donny_ has joined #ocaml
middayc has quit []
bzzbzz has quit ["leaving"]
donny has quit [Read error: 110 (Connection timed out)]
Jedai has quit ["KVIrc 3.2.4 Anomalies http://www.kvirc.net/"]
wy has joined #ocaml
ben has joined #ocaml
<tsuyoshi> hcarty: I don't think it needs to
ben is now known as ziph
thelema has quit [Read error: 110 (Connection timed out)]
thermoplyae has joined #ocaml
awesame has quit []
morner has quit ["let's try a reboot"]
^authentic has joined #ocaml
thermoplyae has left #ocaml []
palomer__ has joined #ocaml
<palomer__> hellp
<palomer__> hello
<palomer__> is it possible to get around the value restriction with type annotations?
authentic has quit [Read error: 110 (Connection timed out)]
^authentic is now known as authentic
<qwr> palomer__: what value restriction?
<qwr> about generic types?
<qwr> palomer__: only on object methods afaik
thelema has joined #ocaml
<hcarty> tsuyoshi: Thanks, seems to be working without it
ulfdoz has quit [brown.freenode.net irc.freenode.net]
gaja has quit [brown.freenode.net irc.freenode.net]
gim has quit [brown.freenode.net irc.freenode.net]
ppsmimou has quit [brown.freenode.net irc.freenode.net]
cygnus_ has quit [brown.freenode.net irc.freenode.net]
ertai has quit [brown.freenode.net irc.freenode.net]
cmeme has quit [brown.freenode.net irc.freenode.net]
qwr has quit [brown.freenode.net irc.freenode.net]
ertai has joined #ocaml
ulfdoz has joined #ocaml
gaja has joined #ocaml
qwr has joined #ocaml
cmeme has joined #ocaml
ppsmimou has joined #ocaml
gim has joined #ocaml
a13x has quit [Read error: 113 (No route to host)]
a13x has joined #ocaml
ttamttam has joined #ocaml
ttamttam has left #ocaml []
wy has quit [Read error: 110 (Connection timed out)]
goalieca has quit ["Ex-Chat"]
hordf has joined #ocaml
love-pingoo has joined #ocaml
petchema has joined #ocaml
Demitar_ has joined #ocaml
Demitar has quit [Read error: 104 (Connection reset by peer)]
ppsmimou has quit ["Leaving"]
ppsmimou has joined #ocaml
OChameau has joined #ocaml
Snark has joined #ocaml
Mr_Awesome has quit ["aunt jemima is the devil!"]
a13x has quit [Read error: 113 (No route to host)]
Yoric[DT] has joined #ocaml
seafood_ has quit []
dwmw2_gone is now known as dwmw2
Tetsuo has joined #ocaml
coucou747 has joined #ocaml
Snark has quit ["Ex-Chat"]
prince has joined #ocaml
hkBst has joined #ocaml
seafood_ has joined #ocaml
middayc has joined #ocaml
ppsmimou has quit [Remote closed the connection]
mwc has joined #ocaml
seafood_ has quit []
ppsmimou has joined #ocaml
Yoric[DT] has quit [Read error: 110 (Connection timed out)]
middayc_ has joined #ocaml
Yoric[DT] has joined #ocaml
AxleLonghorn has joined #ocaml
middayc has quit [Read error: 110 (Connection timed out)]
l_a_m has joined #ocaml
Jedai has joined #ocaml
bongy has joined #ocaml
hordf has quit ["Bye"]
AxleLonghorn has left #ocaml []
<ziph> Can anyone think of a way to do something similar to a List.iter but with a call to a function between each item? I.e. if I have "write" as a function with a side effect and [1, 2, 3] I want to write "1, 2, 3".
<Smerdyakov> You probably want a new higher-order function. Are you asking for suggestions for its type?
<ziph> No, I'm trying to think of a way to do it with List.* since I'll only be doing it once in this application. ;)
<ziph> It looks like a fold but with side effects. ;)
<petchema> btw [1, 2, 3] is an (int * int * int) list
<ziph> [1; 2; 3] rather
<Smerdyakov> ziph, there's no good way to do it with [List.*].
<petchema> # (function [] -> () | h :: q -> print_int h; List.iter (Printf.printf ", %d") q) [1;2;3] ;;
<petchema> Or using String.concat, if building the whole string is not a problem
<ziph> petchema: That'll do the trick, thanks. I'll have to write a iterfold1_left one day. ;)
<petchema> # String.concat ", " (List.map string_of_int [1;2;3]) ;;
<petchema> - : string = "1, 2, 3"
AnnTop has joined #ocaml
AnnTop is now known as OatTop
<ziph> It isn't a string, I was just using that as an example. It's a list of tokens that then get joined by something else (that is aware of formatting conventions).
<OatTop> is there a way to read a single charecter from stdin? I've tried using "input_char stdin" but that buffers the input and requires the user to type a charecter and then press return.
<petchema> Unix.select?
<Smerdyakov> OatTop, your question is about your terminal settings, not OCaml.
<ziph> Ocaml can't adjust the terminal settings?
<OatTop> right... can I change the terminal settings somehow within the program to get the desired behavior?
<Smerdyakov> Most people don't realize that, with standard terminal apps, it's not possible to "read a key," in any language. You have to set up your terminal weirdly.
<Smerdyakov> OatTop, you might be headed towards using curses or similar.
<ziph> I must be thinking of output buffering.
<OatTop> curses is a bit too heavy for this application
<Smerdyakov> I don't think you'll find another way that isn't similarly heavy.
<ziph> Curses will either be calling unix functions on the stdin to change it and/or sending VT100 or similar codes to do it. If you can find out what those are (i.e. how you'd do it in C) you could implement that part.
<ziph> If it is just VT100 codes you just need to send the sequences out of stdout.
<Smerdyakov> ziph, except then the application won't work with other terminal emulations....
<ziph> As nice as termcap is, does anything other than VT100 exist these days? ;)
<ziph> But yes, if it is going to be a robustified application you probably want to look in to termcap (if it turns out you can do what you want with terminal codes)
<OatTop> I found this and it worked
<OatTop> thanks for the tips guys
<Smerdyakov> Well, how about that! Good to know. Is it worth it to use all that code? :)
<OatTop> well it works nicely on unix
<OatTop> throws an exception on windows
<OatTop> maybe I need to write the UI in plain C
<ziph> Windows does buffering?
<ziph> That code makes direct operating system calls. You need to wrap it in something that checks the operating system.
<ziph> (Or see if there is an abstraction library already)
postalchris has joined #ocaml
<OatTop> does anybody know the state of cross compiling with ocaml?
<OatTop> that is, building a win32 executable on a linux box
bluestorm has joined #ocaml
<petchema> afaik, cross compilation is not supported
<OatTop> alright... I saw a 2004 thread about it and was hoping things had progressed since then
<petchema> well, if the last thread on the topic is dated from 2004...
<ziph> ...it must be finished by now? ;)
<petchema> the idea must have died
evn has joined #ocaml
<letrec> Hi! Can I write: match compare (i j) with 0 ->...|1->...|-1->... ??
<letrec> I always forget this.
pango has quit [Remote closed the connection]
<Smerdyakov> Why don' t you just try it?
<letrec> I have tried it of course. The result is strange and I don't get why.
<Smerdyakov> What happens?
<zmdkrbou> letrec: it's "compare i j" not "compare (i j)"
<ziph> I'm curious what it compiled to.
<letrec> It's a typo, sorry. Anyway, I'll use if/then/else.
<zmdkrbou> it shouldn't compile (except if this compare is not the usual compare function)
<ziph> Wouldn't i need to be a function too? :)
psnively has joined #ocaml
<zmdkrbou> yes, but it could be :)
dwmw2 is now known as dwmw2_gone
<psnively> Yes, we can!
* zmdkrbou can't
<ziph> letrec, it's ok, we'll engineer a function that i can be that can make it work!
<psnively> :-D
<ziph> "i" could be "fun n o -> (fun n -> n, o)"
<ziph> Then we'd just redefine compare to take a tuple.
pango has joined #ocaml
<ziph> "(fun n -> (fun k -> n, k)) i_value" rather.
<ziph> Argh.
<ziph> Too tired to be working.
<petchema> compare description only says something about result sign, not that the result is within {-1,0,1}
<petchema> also, matching against | -1 -> ... | 0 -> ... | 1 -> ... is not exhaustive, so you get a warning
bongy has quit ["Leaving"]
Morphous has joined #ocaml
<bluestorm> i often use (-) as a compare-like function
<petchema> you could match with | 0 -> ... | p when p > 0 -> ... | p (* when p < 0 *) -> ...
<petchema> bluestorm: beware of overflows
<bluestorm> hm
postalchris has quit ["Leaving."]
mwc has quit ["Leaving"]
Amorphous has quit [Read error: 110 (Connection timed out)]
Linktim has joined #ocaml
psnively has quit []
LordMetroid has joined #ocaml
munga has quit ["Leaving"]
Linktim has quit [Read error: 110 (Connection timed out)]
marmottine has joined #ocaml
evn has quit []
wy has joined #ocaml
letrec has quit []
evn has joined #ocaml
lordmetroid_ has joined #ocaml
goalieca has joined #ocaml
LordMetroid has quit [Connection timed out]
Waleee has joined #ocaml
ygrek has joined #ocaml
Mr_Awesome has joined #ocaml
ttamttam has joined #ocaml
ttamttam has left #ocaml []
OChameau has quit ["Leaving"]
evn is now known as noob
ziph has quit []
a13x has joined #ocaml
middayc has joined #ocaml
middayc_ has quit [Read error: 110 (Connection timed out)]
gene9 has joined #ocaml
gene9_ has joined #ocaml
jlouis_ is now known as jlouis
gene9 has quit [Nick collision from services.]
gene9_ has quit [Read error: 104 (Connection reset by peer)]
love-pingoo has quit [brown.freenode.net irc.freenode.net]
love-pingoo has joined #ocaml
ygrek has quit [Remote closed the connection]
ygrek has joined #ocaml
<a13x> hi
<a13x> how do you pass a reference
<a13x> c equivalent of &x
<thelema> let v = ref 3 in let f r = incr r in f v
<thelema> or f (ref 8) (although this throws away the reference)
<a13x> what do you mean throws away?
<a13x> i have let v = ref 3, i want to pass ref to v because it changes
<thelema> the definition of f returns unit, so whatever gets passed in doesn't get kept anywhere, so it'll get GC'd
gene9 has joined #ocaml
<a13x> i see
<thelema> no, v doesn't change. what v points to changes.
<a13x> yes, you are correct
<pango> just pass v around
<pango> # let v = ref 3 ;;
<pango> # let f r = incr r ;;
<pango> # f v ;;
<pango> # !v ;;
<pango> - : int = 4
<thelema> v *is* the reference.
<thelema> as opposed to:
<thelema> # let v = ref 3;;
<thelema> # let f x = x + 1;;
<thelema> # f !v;;
<pango> (f could have been let f r = r := !r * 42 or whatever; incr was just an example)
<thelema> (note the !)
<thelema> - : int = 4
<thelema> # !v
<thelema> - : int = 3
<a13x> yes but it will not work
<thelema> a13x: what are you trying to do?
<a13x> if i pass v around and it changes later then it will not change in other places
<thelema> ?? if you pass v around, whenever you do !v, you'll get the current value of v, no matter where it was changed.
<a13x> i am trying to update a variable that is shared across different classes
<thelema> when do you dereference v?
<a13x> every time i use it
<thelema> do you dereference v on class initialization?
<a13x> no, every time it is used
<a13x> !v#etc
<thelema> then I don't see any problem with what you're doing. Actual code will help us help you more.
gene9 has quit ["leaving"]
<a13x> class ui width height brd mode
<a13x> brd is a reference
<a13x> let ui = new ui window_width window_height (ref board) ServerMode;;
<thelema> do you do "ref board" every time?
<a13x> actually
<a13x> let me start over, this code is after i added ref to ref
<a13x> let board = ref(new board board_x board_y max_players (fun x y sqr -> broadcast (Position(x,y,sqr))));;
middayc_ has joined #ocaml
<a13x> let ui = new ui window_width window_height board ServerMode;;
<a13x> so if i say board := new ......
<a13x> will that change board in ui?
<thelema> yes
<a13x> ok, great, thanks
jlouis_ has joined #ocaml
StoneNote has joined #ocaml
jlouis has quit [Read error: 110 (Connection timed out)]
jlouis has joined #ocaml
bluestorm has quit ["Konversation terminated!"]
postalchris has joined #ocaml
ita has joined #ocaml
jlouis_ has quit [Read error: 110 (Connection timed out)]
jlouis_ has joined #ocaml
love-pingoo has quit ["Connection reset by pear"]
mwc has joined #ocaml
ygrek has quit [Remote closed the connection]
jlouis has quit [Read error: 110 (Connection timed out)]
marmottine has quit ["Quitte"]
netx has quit [Remote closed the connection]
<a13x> i have a strange problem, GMain.Main.quit (); doesn't seem to terminate the app
ita has left #ocaml []
LordMetroid has joined #ocaml
<thelema> a13x: you could use Pervasives.exit 0
ofaurax has joined #ocaml
<a13x> let me try that
<a13x> works great
<coucou747> ^ parse error near try
lordmetroid_ has quit [Read error: 110 (Connection timed out)]