<AxleLonghorn>
when I attempt to parse ``foo : {2 2 +}''
<AxleLonghorn>
I get a Failure ("lexing: empty token")
<AxleLonghorn>
centered on "foo"
jeanbon has joined #ocaml
LeCamarade|Away has quit [Read error: 60 (Operation timed out)]
komar__ has joined #ocaml
komar_ has quit [Read error: 54 (Connection reset by peer)]
LeCamarade|Away has joined #ocaml
jmou has joined #ocaml
julm has quit [Read error: 110 (Connection timed out)]
<AxleLonghorn>
nevermind, I figured it out
<AxleLonghorn>
the problem was that it was trying to parse "foo " because I forgot to throw away whitespace
AxleLonghorn has left #ocaml []
_zack has joined #ocaml
mjs22 has joined #ocaml
ertai has joined #ocaml
jeddhaberstro has quit [Client Quit]
ulfdoz has joined #ocaml
_zack has quit ["Leaving."]
_zack has joined #ocaml
Submarine has joined #ocaml
Yoric[DT] has joined #ocaml
mjs22 has quit []
hkBst has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
Yoric[DT] has joined #ocaml
verte has quit [Read error: 60 (Operation timed out)]
LeCamarade|Away has quit [Success]
Yoric[DT] has quit ["Ex-Chat"]
ergodick has joined #ocaml
Skolem has joined #ocaml
Submarine has quit [Remote closed the connection]
<Skolem>
What's an example of using Map.IntMap.t? I'm trying type foo = Map.IntMap.t int;; and I get "Error: The type constructor int expects 0 argument(s), but is here applied to 1 argument(s)"
jmou is now known as julm
komar__ has quit ["WeeChat 0.2.6.3-ohshi"]
komar_ has joined #ocaml
jmou has joined #ocaml
julm has quit [Read error: 110 (Connection timed out)]
Amorphous has quit [Connection timed out]
Amorphous has joined #ocaml
palomer has quit [Read error: 113 (No route to host)]
palomer has joined #ocaml
jmou is now known as julm
jado has joined #ocaml
_andre has joined #ocaml
<jado>
hello, i have the weirdest problem ever: http://paste.ubuntu.com/211890/ i don't understand why the output result is always the same, even though it's a random experiment
<C_Tux>
this a computer random, you need to initialize the beast first
<jado>
oh
<jado>
yes forgot that thanks
<jado>
not so weird after all :d
ulfdoz has quit [Read error: 110 (Connection timed out)]
verte has joined #ocaml
qwr has joined #ocaml
<Skolem>
What's an example of using Map.IntMap.t? I'm trying type foo = Map.IntMap.t int;; and I get "Error: The type constructor int expects 0 argument(s), but is here applied to 1 argument(s)"
<qwr>
Skolem: Hashtbl is usually easier to use. You have create specialized functor of the Map
<Skolem>
qrw: Ok, I basically want to represent a bag (multiset) of integers.
<Skolem>
I'm hoping for an efficient implementation in OCaml (this is for a simulation). If Hashtbl is good enough, then great.
<qwr>
Skolem: i've not compared the performance, but i think that hashtbl should be quite fast
<Skolem>
Great, I'll try that.
<Skolem>
What would be the syntax to create a type of Hashtbl mapping ints to ints? I tried various thngs, including : type q = Hashtbl.t (Int, Int);;
<Skolem>
And i got an error on all of them. I googled around for "hashtbl t" but I couldn't find any examples on the first page of results or so.
<_andre>
type t = (int, int) Hashtbl.t
<qwr>
quite like other parametric types in ocaml ('a list etc)
<Skolem>
Beautiful.
<Skolem>
Oh, sure. OK. I already had tihings like "int list", just didn't think to apply them to things like Hashtbl. Nice and consistent now that I see it.
<kaustuv>
Skolem: keep in mind that Hashtbl.add does a destructive update. If you want a persistent (i.e., functional) map, you'd have to use Map
<Skolem>
Ah, good to know.
<jado>
kaustuv: a destructive update? what do you mean?
verte_ has joined #ocaml
verte has quit [Nick collision from services.]
verte__ has joined #ocaml
verte__ is now known as verte
BiDOrD has quit [Read error: 60 (Operation timed out)]
willb has joined #ocaml
verte_ has quit [Read error: 110 (Connection timed out)]
BiDOrD has joined #ocaml
<qwr>
jado: Hashtbl is mutable data structure. Map is immutable
<jado>
qwr: yes but when you Hashtbl.add it does not destruct the previous binding; or maybe the word 'destructive' has nothing to do with that?
verte_ has joined #ocaml
verte has quit [Nick collision from services.]
verte_ is now known as verte
ched_ has quit [Read error: 101 (Network is unreachable)]
ched_ has joined #ocaml
<wysek>
I guess here he meant destructive == modifying an argument
<qwr>
jado: hashtbl allows multiple value associated with key, so add just add's a new one, hiding the previous one. Hashtbl.replace removes the previous one
<qwr>
jado: before adding the new one
<jado>
qwr: yes sure
<jado>
wysek: thanks i see now
C_Tux has quit [Read error: 110 (Connection timed out)]
Asmadeus has quit [Read error: 110 (Connection timed out)]
Jedai has quit [Read error: 113 (No route to host)]
Jedai has joined #ocaml
ambient has joined #ocaml
verte__ has joined #ocaml
jeanbon has quit [".)(.)(."]
verte has quit [Read error: 110 (Connection timed out)]
Submarine has joined #ocaml
verte__ has quit [Read error: 110 (Connection timed out)]
Jedai has quit [Read error: 113 (No route to host)]
BiDOrD has quit []
jeddhaberstro has joined #ocaml
LeCamarade has joined #ocaml
julm has quit [Read error: 110 (Connection timed out)]
ched_ has quit [Read error: 113 (No route to host)]
ergodick1 has joined #ocaml
julm has joined #ocaml
Ched has joined #ocaml
Camarade_Tux has joined #ocaml
<Camarade_Tux>
#stupidites
<Camarade_Tux>
oops
ergodick has quit [Read error: 110 (Connection timed out)]
<palomer>
you're missing an i
<Camarade_Tux>
:D
travisbrady has quit []
ulfdoz has joined #ocaml
Yoric[DT] has joined #ocaml
_zack has quit ["Leaving."]
jado has quit [Read error: 113 (No route to host)]
travisbrady has joined #ocaml
jeddhaberstro has quit [Client Quit]
komar_ has quit ["WeeChat 0.2.6.3-ohshi"]
Yoric[DT] has quit [Remote closed the connection]
travisbrady has quit []
LeCamarade is now known as LeCamarade|Away|
LeCamarade|Away| is now known as LeCamarade|Away
Jedai has joined #ocaml
travisbrady has joined #ocaml
jonafan has joined #ocaml
BiDOrD has joined #ocaml
Yoric[DT] has joined #ocaml
jeddhaberstro has joined #ocaml
Camarade_Tux has quit ["leaving"]
C_Tux has joined #ocaml
Jedai has quit [Read error: 60 (Operation timed out)]
bombshelter13_ has joined #ocaml
Yoric[DT] has quit ["Ex-Chat"]
ergodick1 has left #ocaml []
Jedai has joined #ocaml
BiDOrD has quit [Read error: 60 (Operation timed out)]
travisbrady has quit [Read error: 110 (Connection timed out)]
travisbrady has joined #ocaml
ched_ has joined #ocaml
julm has quit [Read error: 104 (Connection reset by peer)]
jmou has joined #ocaml
rwmjones has quit [Read error: 113 (No route to host)]
Ched has quit [Read error: 101 (Network is unreachable)]
<Skolem>
How do I declare a function of type int -> int that returns its argument unchanged?
<mrvn>
fun x -> x
<Skolem>
I've tried: let foo : (int -> int) x = x;; and let (foo: int->int) x = x; both are syntax errors.
<Skolem>
I want ot add the type annotation, though.
<mrvn>
# let foo x = (x : int);;
<mrvn>
val foo : int -> int = <fun>
<mrvn>
# let (foo : int -> int) = fun x -> x;;
<mrvn>
val foo : int -> int = <fun>
<Skolem>
Ah-ha!
<mrvn>
# let foo (x : int) = x;;
<mrvn>
val foo : int -> int = <fun>
<Skolem>
I think the middle one is what I was looking for.
<Skolem>
Thank you.
<mrvn>
I think the last is best
jonafan has quit [Read error: 104 (Connection reset by peer)]
BiDOrD has joined #ocaml
rwmjones has joined #ocaml
_andre has quit ["leaving"]
slash_ has joined #ocaml
<flux>
let foo : int -> int = fun x -> x (* no parens required *)
Associat0r has quit [Read error: 104 (Connection reset by peer)]
<Skolem>
Oh, nice.
<flux>
the main advantage is that the format is very similar to the one you have in the .mli-file, so it's easier to keep them in syn
<flux>
c
<mrvn>
If you have an mli file then why annotate the ml?
<flux>
why not? I find it's useful to read the types when browsing or editing the code
<flux>
sometimes I write the .mli-file upfront and then make a working version of it with let foo : annotation = fun _ -> failwith "not implemented"
<flux>
also annotating the type gives out the type error earlier than waiting the .ml file to be compiled and finally compared against the interface..
<mrvn>
Would be nice if one could annotate the .ml file so much that one can generate the .mli.
<flux>
yes, it would be nice at times. but on the other hand you don't want a compile time dependency .ml->.mli->.cmi, because that would break separate compilation a bit
<mrvn>
I don't want mli files at all, except for precompiled modules.
<mrvn>
I think that is the only thing I like about Java
<flux>
I think they serve as a great public overview of the module and a place to put in the documentation
<mrvn>
flux: you still have that if it is generated from a single source.
<flux>
and then the .mli-files would depend on .ml-files.
<flux>
also the kind of documentation often seen in .mli-files might not be that spot-on in the corresponding .ml-files
<flux>
perhaps literate programming that would produce both the .ml and the .mli-file in one go..
<mrvn>
I hate that in most cases the mli is purely duplication of the .ml file.
bombshelter13_ has quit []
oriba has joined #ocaml
oriba has left #ocaml []
Fullma has quit [Read error: 113 (No route to host)]
Fullma has joined #ocaml
jmou has quit [Read error: 110 (Connection timed out)]
jmou has joined #ocaml
jmou is now known as julm
* qwr
has usually not written the mli files at all... as the compiler can create cmi from the ml also by exporting everything at toplevel
<qwr>
mrvn: the mli is optional :)
<mrvn>
qwr: but sometimes you need to
willb has quit [Read error: 110 (Connection timed out)]
hkBst has quit [Read error: 104 (Connection reset by peer)]
ulfdoz has quit [Read error: 110 (Connection timed out)]
Jedai has quit [Read error: 113 (No route to host)]
Yoric[DT] has joined #ocaml
Submarine has quit [Read error: 110 (Connection timed out)]