Taaus changed the topic of #ocaml to: http://caml.inria.fr/oreilly-book/
skylan has quit [Excess Flood]
skylan has joined #ocaml
<timmy> if i have a lot of connections that share and modify data like some server might, what would be the best way to separate those connections? using processes or threads or what?
malc has quit ["no reason"]
Rakko has joined #ocaml
<Rakko> Hi. I would like some help building an OCaml program. I have no OCaml coding experience whatsoever, so I don't know if the error is something I can fix or not.
<Rakko> The error message is:
<Rakko> Expecting function has type 'a list -> 'b list
<Rakko> This argument cannot be applied with label ~f
<Rakko> the line it occurs on is: let gaplist = List.map ~f:(findrelation ob dx dy dz) oblist in
<Rakko> the specific problem area seems to be findrelation ob dx dy dz.
<Rakko> Anyone got any advice?
TimFreeman has joined #ocaml
<Rakko> hi
<Rakko> perhaps you could help me?
TimFreeman has left #ocaml []
<timmy> hi
<Rakko> Do you know much about ocaml?
<timmy> started learning it like 5 days ago or so
<timmy> i would probably need more context to be able to fix that code
<timmy> i'm not sure how/where dx, dy, and dz are defined
<Rakko> ok
<timmy> a big guess would be (by looking at the names):
<timmy> let gaplist = List.map (fun ob -> findrelation ob dx dy dz) oblist in
<Rakko> what's fun ob? ~f?
<timmy> ~f seems like they are trying to use a label
<Rakko> I did notice something odd
<timmy> i was thinking that oblist would have all the ob(jects?) that this findrelation function would be called on
<timmy> but i can't read minds yet, so i would need more context about what is going on
<Rakko> from what I understand of the code, findrelation should take five parameters: ob1 dx dy dz ob2. but it only takes ob dx dy dz... unless I'm misunderstanding the syntax
<timmy> ok
<Rakko> did you get the dcc request?
<timmy> try this then
<timmy> i can't dcc
<timmy> let gaplist = List.map (findrelation ob dx dy dz) oblist in
<Rakko> ok
<timmy> that should work then i guess
<timmy> ok
<timmy> did it work?
<Rakko> dunno yet
<Rakko> just take out the ~f: ?
<timmy> yeah
<Rakko> nope
<Rakko> now it says: This expression has type (gaprelation * gaprelation * gaprelation) list
<Rakko> but is here used with type
<Rakko> (f:'a -> init:'b -> 'c) -> 'd -> f:'a -> init:'b -> 'c
<timmy> that doesn't look like the List.map function
<timmy> hmm
<timmy> i'm having trouble getting that url
<Rakko> ok, what is List.map, for a beginner?
<timmy> # List.map (fun x-> x+1) [1;2;3];;
<timmy> - : int list = [2; 3; 4]
<Rakko> oh, sorry.
<timmy> apply a function to every element in a list
<Rakko> try now
<Rakko> ok. what would ~f: mean?
<timmy> it would be like, make the argument named f equal to the value after this
<timmy> so like here is an example
<timmy> <<#let f ~x:x1 ~y:y1 = x1 - y1;;
<timmy> val f : x:int -> y:int -> int = <fun>
<timmy>
<timmy> #f ~x:3 ~y:2;;
<timmy> - : int = 1
<timmy> but i don't think List.map is defined with labels
<timmy> # List.map;;
<timmy> - : ('a -> 'b) -> 'a list -> 'b list = <fun>
<Rakko> ahh
<timmy> but in the last error message you posted, it looks like that function uses labes
<timmy> labels
<timmy> so the ~f: would have been right
<timmy> but it doesn't look like the List.map that i've seen
<timmy> i don't think i'm getting a responce from that http server
<Rakko> that sucks
<Rakko> can I spam you in private?
<timmy> try that dcc again, i'm behind nat but maybe it works if you open the port?
<Rakko> I'm trying now
<timmy> looks like it worked
<Rakko> woo
<timmy> does this file work by itself?
<timmy> is it made to be stand-alon
<timmy> i guess so
<Rakko> no
<Rakko> it's part of a game
<timmy> but is here used with type
<timmy> (f:'a -> init:'b -> 'c) -> 'd -> f:'a -> init:'b -> 'c
<timmy> File "collision.ml", line 151, characters 27-34:
<timmy> that is another line
<timmy> ~init:(ax, ay, az, []) gaplist in
<Rakko> huh?
<timmy> the line i told you to remove ~f: from doesn't give the error anymore
<Rakko> but it gives a new error?
<timmy> yeah later on
<Rakko> oh, my bad
<Rakko> that's the one I told you, but I didn't realize it was a different line
<timmy> ok this one is on a fold_left function
<timmy> and the author uses labels again which is weird
<timmy> like his std library has them or something?
<timmy> i'm guessing you should just remove ~f: and ~init: ?
<Rakko> let's try
<Rakko> File "collision.ml", line 151, characters 5-19:
<Rakko> This expression has type float * float * float * 'a list
<Rakko> but is here used with type (f:'b -> 'c) -> 'd -> f:'b -> 'c
<timmy> new error
<timmy> same thing
<timmy> remove the ~f: and ~init: again and it works for me
<timmy> bash-2.05a$ ocaml collision.ml
<timmy> bash-2.05a$
<Rakko> what version?
<timmy> of what?
<Rakko> ocaml
<timmy> Objective Caml version 3.04
<Rakko> ok
<Rakko> you want me to remove all the ~f: and ~init:?
<timmy> that got it to work for me
<Rakko> ok
<Rakko> me too
<Rakko> now on to other files...
<timmy> heh
<Rakko> next... the line is "if not atrest then begin"
<Rakko> it says atrest is not a bool but is used as one
<Rakko> any way to convert that?
<timmy> what is atrest?
<Rakko> let atrest =
<Rakko> List.fold_left
<Rakko> ~f:(fun atrest hull -> atrest || incollision ob.hull hull
<Rakko> || (topcollision ob.hull hull 0.01) < 0.0)
<Rakko> ~init:false hulls in
<Rakko> take out the ~ labels again, maybe?
<timmy> you should probably ask the author about that
<timmy> they must work for him
<timmy> or something
<timmy> and i don't know how atrest is defined within it self
<Rakko> ok
<Rakko> ok, I took ~f: and ~init: out of that file, and it compiled
<Rakko> and about 3 other files
<Rakko> but now one of them won't compile even when I do that
<Rakko> lev.dmcubes <- List.fold_left [] lev.dmcubes
<Rakko> does [] make any sense?
<timmy> it's an empty list
<timmy> the first argument to a List.fold_left should be a function
<Rakko> ok. the error was This expression has type 'a list but is here used with type 'b -> 'c -> 'b
<Rakko> ugh
<timmy> so it looks like something is missing
<timmy> i guess we could insert a function that does nothing
<Rakko> well... I'm not sure what the intended action here is
<timmy> i can't figure that out either
<timmy> because fold_left doesn't return a list
<timmy> and the lev.dmcubes looks like it is supposed to be a list
<timmy> maybe you could comment it and replace it with () and hope for the best
<Rakko> hehe
<Rakko> replace what with ()?
<Rakko> I think the best course would be to see if I can track the author down
<timmy> yeah
<Rakko> I dunno if I will be able to, since this was a school project written in 2000 and he's probably got other stuff to worry about now
<Rakko> looks like a cool language though
<Rakko> I've been waiting for an excuse to go into it
<timmy> yeah it is one of the best i have got into
<timmy> maybe the best because i can compile it natively unlike most other languages
<Rakko> why, what's "native" for you?
<timmy> elf format for linux
<Rakko> lots of languages compile to Linux ELF :)
<timmy> well, nothing i have liked a lot
<Rakko> ah
<Rakko> I'm impressed though that it can be interactive OR bytecode OR compiled
<timmy> c and c++ would be the best supported which is about their only plus
<timmy> yeah i used some interpreted languages and i got sick of having to put it through an interpreter all the time
<timmy> i need to figure out if i should use processes or threads
<Rakko> eek
<timmy> i'm writing a program to learn ocaml
<Rakko> best way to do it :)
<timmy> basically this server will bind to the specified port given in a config file and i will create a new ____ for each connection so i can block read
<timmy> but i have to share data
<timmy> which seems to make everything a mess
<timmy> but i think i will use locking for that
<timmy> which will be the best way
<timmy> but i don't know whether to use threads or processes because i'm not sure how each work and it is too late tonight for me to do any thinking so i want someone to do it for me
<Rakko> hehe
* gl &
<Rakko> oh?
* Rakko is away: stuf
gl has quit [Read error: 104 (Connection reset by peer)]
gl has joined #ocaml
* Rakko is back (gone 00:48:34)
<Rakko> re gl
gluck has joined #ocaml
Rakko has quit ["bye"]
malc has joined #ocaml
owll has joined #ocaml
owll has quit [Client Quit]
* puffin is back
Yurik has joined #ocaml
malc has quit ["no reason"]
kruskal has joined #ocaml
kruskal is now known as krusyaourt
Yurik has quit ["Client Exiting"]
krusyaourt is now known as krusvaisselle
krusvaisselle is now known as krusdouche
krusdouche is now known as krusguignols
krusguignols is now known as krusfrance2
krusfrance2 is now known as krusf2maths
krusf2maths is now known as krusmaths
steele has joined #ocaml
steele has quit [Client Quit]
steele has joined #ocaml
tmcm has quit [Read error: 110 (Connection timed out)]
krusmaths has left #ocaml []
malc has joined #ocaml
fseee has joined #ocaml
fseee has left #ocaml []
fseee has joined #ocaml
fseee has left #ocaml []
gl has quit [No route to host]
fseee has joined #ocaml
fseee has left #ocaml []
fseee has joined #ocaml
fseee has left #ocaml []
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml