Herrchen has quit [Read error: 110 (Connection timed out)]
Kinners has quit [Read error: 113 (No route to host)]
Kinners has joined #ocaml
CiscoKid has joined #ocaml
CiscoKid has left #ocaml []
Herrchen has joined #ocaml
zorkadi has joined #ocaml
<zorkadi>
anybody awake?
<Kinners>
hi zorkadi
<zorkadi>
hi...
<zorkadi>
i have a 3-07 question.
<Kinners>
don't keep it to yourself then!
<zorkadi>
i have this piece of code that uses 32 bit integers, and apparently exact 32 bit integers are not allowed anymore in 3.07
<zorkadi>
says int is too big.
<zorkadi>
is there any flag or compiler option for backwards compatibility?
<Kinners>
ocaml uses 1 bit in an int for tagging purposes
<simon->
I just read a tutorial, do you use nativeint?
<Kinners>
that hasn't changed in 3.07
<zorkadi>
but apparently you used to be able to do : let a = 0x80000000
<zorkadi>
in the past. no it is not legal.
<Kinners>
I don't know of a compat flag
zorkadi has left #ocaml []
wmg has joined #ocaml
Snark has joined #ocaml
<Snark>
slt
wmg has left #ocaml []
Snark has quit [Read error: 54 (Connection reset by peer)]
malte has quit ["Leaving"]
Snark has joined #ocaml
mof has quit [Remote closed the connection]
Nate75Sanders has joined #ocaml
smimou has joined #ocaml
Kinners has quit [Remote closed the connection]
Snark has quit [Read error: 104 (Connection reset by peer)]
bk__ has joined #ocaml
bk__ is now known as bk_
<bk_>
hi
Snark has joined #ocaml
gim has joined #ocaml
grirgz has quit [Read error: 104 (Connection reset by peer)]
_fab has quit ["bbl"]
__DL__ has joined #ocaml
smimou has quit ["?"]
smimou has joined #ocaml
__DL__ has quit [Remote closed the connection]
grirgz has joined #ocaml
Snark has quit [Read error: 110 (Connection timed out)]
Nate75Sanders has quit ["using sirc version 2.211+KSIRC/1.3.10"]
Snark has joined #ocaml
<sundeep>
hi bk_
<bk_>
hi sundeep
smimou has quit ["?"]
<sundeep>
guys, i have just started to learn ocaml as i would really like to program the functional way
<bk_>
i'm still kinda new to it, too
<sundeep>
but i can't seem to forget my OO roots, i create a class for just about everything which i think is suboptimal in ocaml
<sundeep>
can you suggest how i could make the transition easily
smimou has joined #ocaml
smimou has quit [Remote closed the connection]
<bk_>
heh i can't except "try to forget about imperative and classes for now and try to do as much as possible the functional way"
smimou has joined #ocaml
<sundeep>
hmmm, which book did/do you use to learn ocaml, bk?
<bk_>
the functional approach to programming (cousineau / mauny)
<bk_>
plus serveral introductory texts i found online
<sundeep>
i see
<sundeep>
i am using jason hickey's tutorial, but i get the feeling that i am missing something
<bk_>
i read that, too
<sundeep>
ok, so have you noticed any improvement in your programming abilities because of ocaml?
<sundeep>
basically how has the ride been like?
<sundeep>
any pitfalls?
<bk_>
interesting
<bk_>
ofc there were and are pitfalls, i come from an imperative background so everything looked very unusual in the beginning
maihem has quit ["Client exiting"]
<sundeep>
so, how is it now?
<bk_>
getting better, i find some odd stuff from time to time (polymorphic variants for example) but i think i've got the hang of it
<sundeep>
btw, i find ocaml to be syntactically unintuitive sometimes... is it a problem with ocaml (as opposed to say haskell), or is it my background
<bk_>
i don't know, i've looked at haskell and i find it even more confusing
<sundeep>
o
<sundeep>
i thought haskell was supposed to be more of a 'pure' functional language, so it should be easier for the beginner
<bk_>
i sort of doubt that, you cam write your code in a pure functional way in ocaml, too, if you like
<bk_>
*can
Boojum has joined #ocaml
Snark has quit [Read error: 110 (Connection timed out)]
<sundeep>
i was thinking that ocaml perhaps tries to marry too many features and becomes bloated ala c++
<bk_>
besides, monads seem to be kind of intrinsic to haskell, so eventually you end up using them anyway
<bk_>
ocamls OO appears to be a bit of bloat, i agree
<sundeep>
yeah
<sundeep>
anyway, i guess it is too early for me to make comments on ocaml
<sundeep>
btw, i thought that the ocaml community is active and very helpful
<sundeep>
but there doesn't seem to be much going on this channel
<sundeep>
except for you bk_:)
<bk_>
yes, i can't really comment on ocaml too, yet
<bk_>
and yes, ocamls 'community' seems to be practiacally non-existant, i wonder why that is
<sundeep>
ok, gtg see ya later...
<bk_>
cu
bk_ has quit ["I'll be back"]
bk_ has joined #ocaml
<smimou>
<bk_> and yes, ocamls 'community' seems to be practiacally non-existant, i wonder why that is << that's not true
<smimou>
people just don't have time to stay on an IRC channel
<smimou>
especially on week-ends
<smimou>
but the caml-list for example is fairly active
<bk_>
well yes, the caml-list is, but the caml-list appears to be more oriented towards experienced ppl
<bk_>
ofc, there's the ocaml beginners list, too
<smimou>
yes
<bk_>
i'm thinking more in terms of a wiki, ie. a central place to start if you're looking for all kinds of FAQs & information
<bk_>
ocaml.org doesn't appear to be in very good shape, update-wise
<smimou>
ocaml.org is NOT the official site
<smimou>
it is caml.inria.fr
<bk_>
i know, but the official one is even worse
<smimou>
well I think you've got almost everything you need in the official documentation
<bk_>
almost :> i could use a few more examples about how to put polymorphic variants to good use :>
<Tram>
I regret that there aren't much binding to other libraries :( - but is true that the manual is rather good
Boojum has quit [Read error: 110 (Connection timed out)]
Boojum has joined #ocaml
Boojum is now known as Snark
Nate75Sanders has joined #ocaml
<buggs>
method foldl : 'a. ('a -> #node -> 'a) -> 'a -> 'a -> 'a =
<buggs>
fun f accu n ->
<buggs>
List.fold_left
<buggs>
(fun a (s,n) -> n#foldl f (f a n) n)
<buggs>
accu self#transitions
<buggs>
This method has type ('a -> node -> 'a) -> 'a -> 'a -> 'a
<buggs>
which is less general than 'b. ('b -> node -> 'b) -> 'b -> 'b -> 'b
<buggs>
Someone knows how to work around that ?
fab has joined #ocaml
fab is now known as _fab
Nate75Sanders has quit ["using sirc version 2.211+KSIRC/1.3.10"]
Nate75Sanders has joined #ocaml
smimou has quit ["?"]
noss has joined #ocaml
<lucifer>
is 'a less general than 'b?
<_fab>
lucifer: no
<_fab>
its just another name
<lucifer>
then i dont understand buggs' question :)
<lucifer>
oh you missed that i c:(
<_fab>
which question?
<lucifer>
[15:02] <buggs> This method has type ('a -> node -> 'a) -> 'a -> 'a -> 'a
<lucifer>
[15:02] <buggs> which is less general than 'b. ('b -> node -> 'b) -> 'b -> 'b -> 'b
<lucifer>
[15:03] <buggs> Someone knows how to work around that ?
<buggs>
the problem seems to be with named anonymous variables
<buggs>
i read using _ instead of 'a as type would solve it
<lucifer>
buggs: well it uses 'b only if it has used 'a and needs somethnig that can be different
<buggs>
i don't know where to use _ though
<buggs>
lucifer, no 'a and 'b are the same
<_fab>
i don't understand your question
<buggs>
the above is the error message
<_fab>
'a -> 'a only restricts that the function has the same input and output type
<_fab>
'b -> 'b is exactly the same
<_fab>
oh
<buggs>
yes hence the problem with compiler not being able to unify them
<lucifer>
what does 'b. in front of the rest mean?
<buggs>
that it doesn't get propagated to the class
Nate75Sanders has quit ["using sirc version 2.211+KSIRC/1.3.10"]
mattam_ has quit [Read error: 110 (Connection timed out)]
Snark has quit [Read error: 110 (Connection timed out)]
Snark has joined #ocaml
cmeme has quit [Connection reset by peer]
cmeme has joined #ocaml
cmeme has quit [Read error: 54 (Connection reset by peer)]
noss has quit ["Leaving"]
noss has joined #ocaml
Tram is now known as Diablo
Diablo is now known as Tram
cmeme has joined #ocaml
GreyLensman has joined #ocaml
cmeme has quit [Read error: 54 (Connection reset by peer)]
cmeme has joined #ocaml
gim has quit ["bbw"]
bk_ has quit ["I'll be back"]
Xcalibor has joined #ocaml
smimou has joined #ocaml
<grirgz>
plop
maihem has joined #ocaml
bk_ has joined #ocaml
mij has joined #ocaml
GreyLensman has quit ["Leaving"]
gim has joined #ocaml
buggs^z has joined #ocaml
tea has quit ["using sirc version 2.211+KSIRC/1.3.10"]
buggs has quit [Read error: 60 (Operation timed out)]
tea has joined #ocaml
<Snark>
good night
Snark has left #ocaml []
<bk_>
is it possible to use a classtype for optional arguments ?
<karryall>
bk_: what do you mean ?
<bk_>
ie this is from the o'reilly book :
<bk_>
let print_integer ?file:opt_f n =
<bk_>
and i've come across a definition like this
<bk_>
val connector : ?proxy:#client_socket_connector ->
<bk_>
and apparently client_socket_connector is a class
<karryall>
yes
<karryall>
you can use any type
<bk_>
oh ok
<karryall>
even polymorphic ones
<bk_>
ok thanks
_fab has quit [Read error: 113 (No route to host)]
karryall has quit ["tcho"]
Nic has joined #ocaml
<Nic>
hello
<Nic>
Is there an equivalent for the caml light function read_key in ocaml ?
<Nic>
There is a read_key in the modules Graphics, but I don't use it
cmeme has quit [Read error: 54 (Connection reset by peer)]
cmeme has joined #ocaml
<Nic>
I'm trying to make a sokoban game
<bk_>
sokoban is a fun game :>
<Nic>
I just need to make the controls and I'll have a playable game
<Nic>
I'll maybe compile caml light again to use read_key ... But I had the feeling ocaml was better supported in linux
<Nic>
With the gentoo distribution, emerge ocaml and it's done, the whole thing is working great
<bk_>
imho caml light is not being developed any further
<Nic>
yup but I'm learning caml light, and not ocaml with my teachers
<Nic>
all the functions they give are for caml light
<bk_>
shouldn't be too difficult to make a transition from caml light to ocaml for you then
<Nic>
I found the equivalents for the others function, but for read_key I didn't manage
<bk_>
hm read_key
<Nic>
I've spent many hours yesterday searching on the web without success
<Nic>
I need to implemente the controls for the game
<bk_>
graphics.mli:val read_key : unit -> char
<Nic>
yes
<Nic>
but I don't use the graphic module
<Nic>
it's text based
<bk_>
you don't have to 'use' the graphics module, ie just open graphics and use only the read_key function should work, no ?
<Nic>
I use print_char to display the game
<Nic>
hmm
<bk_>
#load "graphics.cma";;
<bk_>
Graphics.read_key ;;
<bk_>
- : unit -> char = <fun>
<Nic>
it isnt an ideal solution but it may work
<Nic>
I have to open a graph to use it
<Nic>
a graph that the programs don't use ;)
<Nic>
I've tried : let c = input_char stdin in match c with ...
<Nic>
but it doesnt work
<bk_>
# let c = input_char stdin ;;
<bk_>
d
<bk_>
val c : char = 'd'
<Nic>
yes but in my programs it doesnt work
<bk_>
oic
<Nic>
match c with | z -> deplace Nord ...
<Nic>
when I press z, it doesnt "deplace Nord"
<Nic>
I see Math failure
<Nic>
match
<Demitar>
'z'
<Nic>
yes sorry
<Nic>
'z'
<Nic>
is spam authorized here ? :)
<bk_>
dunno, i never spammed here
<Nic>
hmm read_key of module Graphics isnt a good idea in my case
<Nic>
it may work with input_char stdin but don't know how
<Nic>
why must I press enter after pressing a character?
<Nic>
a key
<bk_>
yes
<Nic>
I just want to press a key, then the program makes the corresponding action
<bk_>
perhaps you'd like to take a look at the general input functions of the pervasives module and see whats best for you
<Nic>
already done
<mellum>
That's just the way things work on Unix.
<mellum>
You need to fiddle with the terminal settings to change it.
<Nic>
ha?
<Nic>
I don't have a lot of settings in my term
<Nic>
mellum what are you using? linux ?
<bk_>
Under other systems (e.g. Unix, VMS in other modes), the part of the operating system responsible for serial input (often called the ``terminal driver'') must be placed in a mode which turns off line-at-a-time processing, after which all calls to the usual input routines (e.g. read, getchar, etc.) will return characters immediately.
<bk_>
(taken from comp.lang.c FAQ)
<Nic>
ha yes
<Nic>
but how do I do that in linux?
<Nic>
maybe a line in .bashrc
<mellum>
In C, with the curses/ncurses library. Probably there is something similar for Ocaml.
<Nic>
I should maybe ask a guy in my class who manage to make this program... But I really hate him :p
<Nic>
I didnt think it was so complicated if he managed to do it
Nic_ has joined #ocaml
Nic has quit [Read error: 104 (Connection reset by peer)]
noss has quit [Read error: 110 (Connection timed out)]
<bk_>
perhaps 'stty' with -icanon does what you want, not sure tho
Nic_ is now known as Nic
<Nic>
can I post my main function?
<Nic>
8 lines
Demitar has quit ["Bubbles..."]
<bk_>
i guess you can
<Nic>
let main () = print_laby t ;
<Nic>
while not (laby_fini t) do
<Nic>
let c = read_key () in match c with
<Nic>
| 'z' -> deplace Nord
<Nic>
| 's' -> deplace Sud
<Nic>
| 'q' -> deplace Ouest
<Nic>
| 'd' -> deplace Est ;
<Nic>
print_laby t done ;;
<Nic>
I tried let c = input_char stdin too, it seems better but dont work either
<Nic>
hmm really strange
GreyLensman has joined #ocaml
<bk_>
i guess either you have to use ncurses somehow or put your terminal in a different input mode
<Nic>
with this match : let c = input_char stdin in match c with | 'z' -> deplace Nord | 's' -> deplace Sud | 'q' -> deplace Ouest | 'd' -> deplace Est ; | _ -> failwith "main"
<Nic>
I type z , then press enter and I get : Fatal error: exception Failure("main")
<Nic>
z isnt even matched
<Nic>
q s d returns an error, but its normal as I cant move in these directions
<bk_>
:shrug:
<Nic>
I'm lost
<Nic>
how can I match Enter ?
<Nic>
it isnt '/n' ?
<Nic>
ha no, it was in C
Xcalibor has quit ["Leaving"]
<Nic>
ha I'm starting to understand
<Nic>
in fact the program read the key, I dont need to press enter
<Nic>
but the action on the environment are put in memory
<Nic>
and are done at end
<Nic>
thats why nothing is done until it raises an error
<Nic>
I think I can change the program itself , but don't know how
<Nic>
yes!!! I finally found a workaround :) my game works, this rule
<Nic>
but I have to press a key + enter each time
<Nic>
let main () = print_laby t ;
<Nic>
while not (laby_fini t) do
<Nic>
let c = input_char stdin in try match c with
<Nic>
| 'z' -> deplace Nord ; print_laby t
<Nic>
| 's' -> deplace Sud ; print_laby t
<Nic>
| 'q' -> deplace Ouest ; print_laby t
<Nic>
| 'd' -> deplace Est ; print_laby t
<Nic>
| _ -> failwith "main" ;
<Nic>
with Failure("main") -> () ;
<Nic>
done ;
<Nic>
if anyone has an idea to improve it, it would be great :)
maihem has quit ["Read error: 54 (Connection reset by chocolate)"]
<mellum>
why not just | _ -> ()
<Nic>
ho yes lol
<Nic>
I'm dumb
<Nic>
I still have to press enter, do u really think I can't change my program for thatN
<Nic>
?
<Nic>
I've to change my term? you've no idea how to do it?
<Smerdyakov>
You can't use the basic IO functions for that.
<Smerdyakov>
You need to find a way of getting keypresses directly.
<Nic>
really?
<Nic>
so it would be a lot more complicated?
<Nic>
I've already spent any hours yesterday searching on the web