gl changed the topic of #ocaml to: OCaml 3.07 ! -- Archive of Caml Weekly News: http://pauillac.inria.fr/~aschmitt/cwn , A tutorial: http://merjis.com/richj/computers/ocaml/tutorial/ , A free book: http://cristal.inria.fr/~remy/cours/appsem, Mailing List (best ml ever for any computer language): http://caml.inria.fr/bin/wilma/caml-list | http://icfpcontest.org/ !!
cjohnson has quit [Read error: 60 (Operation timed out)]
cjohnson has joined #ocaml
tea has joined #ocaml
shammah has joined #ocaml
sundeep has quit [Connection timed out]
skylan has quit ["bbiab, UPS"]
CiscoKid has quit ["http://lice.codehack.com"]
sundeep has joined #ocaml
sundeep has quit [Client Quit]
sundeep has joined #ocaml
gim has quit []
bzzbzz has joined #ocaml
kinners has joined #ocaml
psb has joined #ocaml
psb has quit [Client Quit]
psb has joined #ocaml
psb_ has joined #ocaml
psb has quit [Read error: 60 (Operation timed out)]
[1]platypus has joined #ocaml
<[1]platypus> what does List.fold_left mean ?
benja has joined #ocaml
<benja> hey all
<[1]platypus> hey
<benja> I have a type t = A of int | B of float;; and a function compute : int -> t. Is there an ocaml trick to parametrise the function to determine that it'll return A or B ?
<Riastradh> I'm not quite sure I understand your question.
<benja> To avoid a match after the function
<benja> let say that my function can return a composite type (A or B) but when I want to use it, I want it to return a A value.
<Riastradh> That would rather depend on what that function does, wouldn't it?
<benja> I don't know how to do it but here is how I see it. x : int = read "file" `INT or y : float = read "file" `FLOAT
<benja> so I want to pass an extra parameter which tell the type of the returned value
<benja> does that make sense ?
<Riastradh> I suppose you could just use a sentinel value -- e.g., write [[let A x = read "file" (A 0)]] or [[let B x = read "file" (B 0.0)]].
<benja> ok I see
<benja> so my function would have a type : string -> 'a -> 'a but how can I restraint the type of 'a to an element of type t ?
<sundeep> platypus: i'll paste the meaning from the online reference:
<sundeep> List.fold_left f a [b1; ...; bn] is f (... (f (f a b1) b2) ...) bn.
<Riastradh> benja, I don't believe you can have a function like that.
<benja> the class system is able to do that with a parametric class but is there parametric functions ?
<benja> if i try 'let x y = match y with int -> () | float -> ()' in the toplevel. the type of the function is 'val x : 'a -> int = <fun>'
<benja> all right I'll write read_{type} function for each type...
bk_ has joined #ocaml
bzzbzz has quit [Read error: 60 (Operation timed out)]
skaller has quit [Read error: 110 (Connection timed out)]
skaller has joined #ocaml
benja has quit ["Leaving"]
franco has joined #ocaml
franco has left #ocaml []
psb_ has quit ["ChatZilla 0.8.23 [Mozilla rv:1.3/20030312]"]
vezenchio has joined #ocaml
skylan has joined #ocaml
CiscoKid has joined #ocaml
skylan has quit [Read error: 104 (Connection reset by peer)]
skylan has joined #ocaml
kinners has quit ["leaving"]
<[1]platypus> how do i get access to the filename module?
[1]platypus has quit [zelazny.freenode.net irc.freenode.net]
[1]platypus has joined #ocaml
[1]platypus has quit [zelazny.freenode.net irc.freenode.net]
[1]platypus has joined #ocaml
<[1]platypus> when a character is placed in double quotes ocaml treats it as a char but in single it's treated as a string ?
<bk_> the other way around
<bk_> "a" is a string 'a' is a char
<[1]platypus> # String.rindex "cock" "k";;
<[1]platypus> Characters 21-24:
<[1]platypus> String.rindex "cock" "k";;
<[1]platypus> ^^^
<[1]platypus> This expression has type string but is here used with type char
<[1]platypus> ops
<[1]platypus> sorry sorry
<[1]platypus> din mean to flood
<[1]platypus> i was trying to paste it elsewhere
<CiscoKid> val rindex : string -> char -> int
<bk_> String.rindex "cock" 'k'
<simon-> is ocaml platypus-compatible?
<[1]platypus> bk_, yeah but what is the error reffering to ?
<[1]platypus> simon-, :)
<[1]platypus> simon-, at this point i guess not
<simon-> platypus, look at what CiscoKid wrote.
<bk_> you're using a string "k" instead of a char
<CiscoKid> It's telling you that you used a string where a char was wanted.
<bk_> This expression has type string mean the "k"
<CiscoKid> I wonder how much easier ocaml would be if that error was restructured a bit. :)
<simon-> ...but is here used with type char (referring to the "char" bit in what CiscoKid wrote)
<[1]platypus> ok
<[1]platypus> got it :)
<sundeep> CiscoKid: i wonder why no one has done anything about the error messages
<[1]platypus> which module do i use if i want to read and write to a file ?
<sundeep> platypus: the module Pervasives which is open by default, you can also use Printf
<CiscoKid> There's a lot of improvements that could be made to ocaml, but they don't seem to be very fast to accept improvements.
[1]platypus has quit [zelazny.freenode.net irc.freenode.net]
[1]platypus has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
Snark has joined #ocaml
<Snark> slt
Snark has quit [Read error: 104 (Connection reset by peer)]
<simon-> blt
Snark has joined #ocaml
<[1]platypus> what does this mean ??
<[1]platypus> in_channel -> buf:string -> pos:int -> len:int -> int
<CiscoKid> It's labeled.
<[1]platypus> i am reading the manual and it says this :
<[1]platypus> really_input : in_channel -> buf:string -> pos:int -> len:int -> unit
<[1]platypus> Read len characters from the given channel, storing them in string buf, starting at character number pos. Raise End_of_file if the end of file is reached before len characters have been read. Raise Invalid_argument "really_input" if pos and len do not designate a valid substring of buf.
<[1]platypus> but what i don understand is ... how do i change the value of len ??
<[1]platypus> i mean say i want it to read till the length 5, how do i do it
<CiscoKid> Set the length to 5.
<[1]platypus> how ?
<CiscoKid> How are you using a value other than 5 now?
<simon-> platypus, did you read any tutorials at all?
<[1]platypus> simon-, i did
<[1]platypus> well i did this : i open up a file using open_in ... so it gave me a in_channel type
<[1]platypus> then i sent the in_channel to be used by really_input
<CiscoKid> OK, which part of the manual are you reading to get a labeled really_input? Pervasive's isn't labeled.
<[1]platypus> in_channel is abstract
<CiscoKid> What exactly are you doing?
<[1]platypus> CiscoKid, i am trying to read a local file
<CiscoKid> That's not exactly what you're doing, that's your goal.
<[1]platypus> okay
<simon-> *snicker*
* [1]platypus slaps simon- a few times
<CiscoKid> Where'd that doc come from? that's not what pervasives looks like.
<[1]platypus> ummm ... okay i am creating an in_channel object and sending it to really_input
<CiscoKid> That's a description of what you're doing. What's the code look like?
[1]platypus has quit [zelazny.freenode.net irc.freenode.net]
<CiscoKid> damn netsplit
[1]platypus has joined #ocaml
<[1]platypus> CiscoKid, i see what u mean i guess i was looking at the wrong manual :(
<CiscoKid> That was just weird.
<[1]platypus> oh the page u mean ?
<[1]platypus> i dunno found it using google
<CiscoKid> Yeah, it was like a parallel universe.
<[1]platypus> :)
<[1]platypus> CiscoKid, how do you label lists ?
<[1]platypus> f ~x ~y -> x - y;; will label it x and y but they are both integers ... how do i label other types ?
<CiscoKid> There are predefined labeled modules for a lot of things.
<CiscoKid> Although, from reading that documentation, I don't see how that stuff is labeled.
bk_ has joined #ocaml
CiscoKid has quit ["sleeping"]
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
Iter has joined #ocaml
dobrek has joined #ocaml
gim has joined #ocaml
kosmikus|away is now known as kosmikus
Iter has quit [zelazny.freenode.net irc.freenode.net]
[1]platypus has quit [zelazny.freenode.net irc.freenode.net]
Iter has joined #ocaml
[1]platypus has joined #ocaml
kinners has joined #ocaml
adc has joined #ocaml
Hipo has quit ["leaving"]
[1]platypus has quit [zelazny.freenode.net irc.freenode.net]
Iter has quit [zelazny.freenode.net irc.freenode.net]
Iter has joined #ocaml
Iter has left #ocaml []
Iter has joined #ocaml
platypus has quit [Read error: 113 (No route to host)]
platypus has joined #ocaml
bk_ has joined #ocaml
kinners has quit ["zzz"]
Iter has quit ["Leaving"]
platypus has quit [Read error: 104 (Connection reset by peer)]
cjohnson has quit [Read error: 60 (Operation timed out)]
cjohnson has joined #ocaml
platypus has joined #ocaml
karryall has joined #ocaml
monotonom has joined #ocaml
trch has joined #ocaml
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
bk_ has joined #ocaml
platypus has quit [Read error: 104 (Connection reset by peer)]
vezenchio has quit ["look at you, hacker, a pathetic creature of meat and bone, panting and sweating as you run through my corridors; how can you ]
cjohnson has quit [Read error: 60 (Operation timed out)]
cjohnson has joined #ocaml
tea has quit [Read error: 54 (Connection reset by peer)]
karryall has quit ["."]
carm has quit ["Client Exiting"]
cjohnson has quit [Read error: 110 (Connection timed out)]
cjohnson has joined #ocaml
kosmikus is now known as kosmikus|away
<Snark> good night
Snark has left #ocaml []
monotonom has quit ["Don't talk to those who talk to themselves."]
bk_ has quit ["Leaving IRC - dircproxy 1.1.0"]
mattam has quit [Read error: 60 (Operation timed out)]
mattam has joined #ocaml
CiscoKid has joined #ocaml
CiscoKid has quit [Client Quit]
CiscoKid has joined #ocaml
mmc is now known as mmc_away
platypus has joined #ocaml
gim has quit []
sundeep has quit ["Client exiting"]
adc has quit ["Leaving"]
Iter has joined #ocaml
Iter has quit [Client Quit]
Iter has joined #ocaml
mmc_away is now known as mmc
sundeep has joined #ocaml
monotonom has joined #ocaml
platypus_ has joined #ocaml
<CiscoKid> Yeah, I grabbed one of those problems and rolled out an ocaml solution last night.
Iter has quit ["Leaving"]
shammah has quit ["Leaving"]
shammah has joined #ocaml