<mcstar>
the guy says, that order of definition of functions in a file doesnt matter
<mcstar>
but thats clearly not the case when i try to run the example
<mcstar>
what am i missing?
<_habnabit>
mcstar, he's incorrect
ousado has joined #ocaml
<mcstar>
ah great, thanks
<_habnabit>
lexical order in files matters
<mcstar>
he must be confused with haskell
<_habnabit>
I could be wrong, but I have _never_ seen anything that suggests you could reorder the statements like is stated here
<mfp>
this is just wrong (and not grammatical?) -> "In Ocaml, so you can define a function after you call it, so long as it is called and defined in the same script"
<_habnabit>
yeah, that grammar is funky
<f[x]>
wtf really
<mfp>
maybe the author was testing this in the toplevel and just picked up earlier definitions when trying with different orders
<mcstar>
:S
<f[x]>
good excuse for the _book_ author
<mcstar>
The sequence point is actually an operator, like +. It takes a unit on the left and anything on the right and returns the right
eni has joined #ocaml
<mcstar>
he is explaining ;
<mcstar>
but if its a normal operator, like (+), why cant i print its type?
osa1 has joined #ocaml
<_habnabit>
i wouldn't say it's 'like +'
<_habnabit>
if anything, it's like :: -- they're both ostensibly operators, but are implemented as syntax
silver has joined #ocaml
<_habnabit>
you can't get their value and you can't reassign to their value
<mcstar>
and the 'unit' type is not enforced, it gives only a warning, if the left expression actually returns anything else but unit
<_habnabit>
right
ankit9 has quit [Read error: Operation timed out]
<mcstar>
and its weird, that he suggests to "#use "printf.ml";;", and not "open Printf;;", he never mentions 'open' in the book, afaics
<_habnabit>
could be a bad book
eni has quit [Quit: Leaving]
<mcstar>
is there a reason, that the ocaml prompt # would change to >>> ?
<mcstar>
multi-line input maybe?
f[x] has quit [Quit: Leaving]
<mcstar>
>>> michael = 1
<mcstar>
>>> print_twice michael
f[x] has joined #ocaml
<mcstar>
oh
<mcstar>
i get it
<mcstar>
he just edited the Python version of the book
<mcstar>
Think like a computer scientist is in Python originally
ankit9 has joined #ocaml
<mcstar>
ok, theres another error, he forgot to use "" instead of '', and the example gives wrong output
<mcstar>
i wont bother you guys again with that book
ankit9 has quit [Ping timeout: 245 seconds]
avsm has joined #ocaml
<mcstar>
(maybe except when i see some serious errors)
<mcstar>
i read some bad reviews of Practical Ocaml
<mcstar>
what is the most recommended guide to ocaml nowadays?
<_habnabit>
ssbr_, delete all of your .cmx{a,} files and try again
<ssbr_>
Apparently this means "recompile Buddy"
<ssbr_>
(works now)
eikke has joined #ocaml
<gnuvince>
Can anyone explain to me the signature mismatch in the following code, and how to possibly fix it? http://ideone.com/n7Q5t
jamii has quit [Ping timeout: 240 seconds]
Yoric has joined #ocaml
ankit9 has quit [Quit: Leaving]
eikke has quit [Ping timeout: 244 seconds]
oriba_ has joined #ocaml
oriba has quit [Read error: Operation timed out]
<ssbr_>
I suppose there is no way to debug code that is compiled to machine code, right? Only bytecode?
<ssbr_>
this project has makefiles I have a hard time editing. :<
<ssbr_>
(so making it output bytecode seems.. difficult)
<Hodapp>
Sometimes with Makefiles you can find a variable used globally that dictates what line it compiles with
<_habnabit>
ssbr_, 'debug' how
<ssbr_>
_habnabit: with a debugger.
<_habnabit>
ocamldebug?
<ssbr_>
I want to play with a variable at a certain step in the program
<ssbr_>
_habnabit: I think so
<_habnabit>
ha ha, good luck
<ssbr_>
:(
<Qrntz>
ssbr_, a patch that allows for debugging native ocaml code with gdb is ported to svn trunk and will be released in 3.13 (aka 4.0)
<Qrntz>
still, «Reading and writing OCaml values is not supported; however, it is possible to read OCaml values (when you know its address) using the mlvalues.py script from ygrek»
<ssbr_>
What do you do then? just step through without seeing anything?
<Qrntz>
the description sums it up.
<ssbr_>
It says "debug", but I'm not sure what that means.
<ssbr_>
Well, anyway, it's no use to me for now. But thank you.
<Qrntz>
you're welcome
<gnuvince>
Can anyone explain to me the signature mismatch in the following code, and how to possibly fix it? http://ideone.com/n7Q5t
eikke has joined #ocaml
<Ptival>
there is probably some need for a variance annotation of a "with ..." annotation, but I'm not an expert enough :)
<Ptival>
s/of/or/
Sablier has quit [Ping timeout: 260 seconds]
kolera has joined #ocaml
kolera_ has joined #ocaml
kolera_ has quit [Read error: Connection reset by peer]
kolera has quit [Client Quit]
kolera has joined #ocaml
kolera_ has joined #ocaml
kolera_ has quit [Client Quit]
kolera has quit [Client Quit]
kolera has joined #ocaml
<Ptival>
module AssocList : DICTIONARY with type 'a t = (string * 'a) list
<Ptival>
fixes the problem but does not look quite cool
<Ptival>
gnuvince: I think I can sort of explain the problem
<Ptival>
when you write "module AssocList : DICTIONARY", you say to the external world "you may only assume that AssocList satisfies DICTIONARY"
kolera has quit [Client Quit]
<Ptival>
In particular, the DICTIONARY sig is abstracted over t
<Ptival>
so when you "include AssocList" in AssocListPlus, you don't really include is as a "textual" include, but rather as part of the outside world, that does not know more than what DICTIONARY tells
<Ptival>
so, the fix is to tell more
Sablier has joined #ocaml
kolera has joined #ocaml
<Ptival>
this is often referred to as a "sharing constraint"
Yoric has quit [Ping timeout: 264 seconds]
eikke has quit [Ping timeout: 265 seconds]
<gnuvince>
Ptival: thanks
<gnuvince>
And indeed, it's kinda ugly with the "with type ..." part :)
Snark has quit [Quit: Quitte]
jamii has joined #ocaml
amness4 has joined #ocaml
amness4 has left #ocaml []
mcstar has joined #ocaml
<mcstar>
how come (-) is polymorphic? i.e. it accepts ints and floats? jason hickey says you need -. for floats
<_habnabit>
mcstar, it isn't polymorphic
<_habnabit>
it also doesn't accept ints and floats
<mcstar>
so - in -5 is not a unary operator?
<_habnabit>
the unary operator is (~-), not (-)
<_habnabit>
ocaml just allows it to be written as - sometimes
<mrvn>
-5 is a int literal -5 instead of (-) 5
<mcstar>
he was pretty thorough in listing the operators, he should have mentioned this there
<_habnabit>
is this still the same book? it doesn't seem very good
<mcstar>
btw, i found an error in his assoc function
<mcstar>
_habnabit: no, this is the one someone suggested here
<mcstar>
can there be user defined unary operators?
<_habnabit>
sure
<_habnabit>
unary operators all start with ~
<_habnabit>
(except (!))
<mrvn>
Imho that shouldn't parse.
Reventlov has quit [Ping timeout: 245 seconds]
<mcstar>
so in 1 + + + + 1;; the first + is binary, the others are unary?
<_habnabit>
yes
<mrvn>
why does the grammar allow multiple unary operators?
Kakadu has left #ocaml []
<_habnabit>
why not?
<mrvn>
because that makes no sense
Yoric has quit [Ping timeout: 260 seconds]
<_habnabit>
it could, if you define your own unary operator
<mcstar>
_habnabit: what troubles me, is that you dont have to put ~ in front of them
<_habnabit>
# let (~++) = succ in 1 + ~++ ~++ ~++ ~++ 2;;
<_habnabit>
- : int = 7
<_habnabit>
etc.
<Ptival>
multiple unary operators sometimes make sense
<Ptival>
I'm thinking ~ ~ P in logic
<mcstar>
_habnabit: no, i mean in my exmaple, + is automatically made into a unary operator ~+
<mcstar>
if i unerstand correclty
<_habnabit>
mcstar, yes, I know
<_habnabit>
mcstar, that was not for you
<mcstar>
k
<mcstar>
_habnabit: can you help me understand why an eta expansion alleviated monomorphism?
<mcstar>
s*
Reventlov has joined #ocaml
<_habnabit>
mcstar, ocaml only allows polymorphism in function parameters
emmanuelux has joined #ocaml
snearch has quit [Quit: Verlassend]
<mcstar>
_habnabit: how is this different from haskell's polymorphism?
thomasga has quit [Quit: Leaving.]
<_habnabit>
I don't know haskell
<mcstar>
in haskell, id id :: a -> a
<mcstar>
while in ocaml, id id : '_a -> '_a
<mrvn>
mcstar: '_a means you forgot to set the type contravariant.
<mrvn>
iirc
<mcstar>
i never heard it desribed that way
<mcstar>
it becomes basically an existential type, in haskell lingo i think
<mrvn>
'_a means "one of something but I don't yet know what" while you want "anything"
<mcstar>
yes
<mcstar>
i dont 'want', im just asking about the differences between the 2 type systems
<mrvn>
# let f x = (id id) x;;
<mrvn>
val f : 'a -> 'a = <fun>
<mcstar>
yes
<mrvn>
ik, not a contravariant problem, a value restriction problem
<mrvn>
ok
<mcstar>
the book argues, that this behavior is necessary, because ocaml is impure, and there are mutable types
<mcstar>
but unfortunately either im dump, or it isnt explained very well
<mcstar>
dumb*
<mrvn>
I don't think one would put it like that but I think that is essentially true. The value restriction comes into play so that you can't mess up the type in mutables.
<jonafan>
doesn't haskell have similar problems with typeclasses?
<Ptival>
I don't think they are "similar"
<mrvn>
Basically consider: let x = ref [] let () = x := [1] let () = x := ["s"]
<jonafan>
yeah i guess not
Yoric has joined #ocaml
osa1 has joined #ocaml
manu3000 has joined #ocaml
<mcstar>
mrvn: well, in haskell that kind of thing 'ref []' would just create an action, and that wouldnt get evaluted, and you could use it many times, while in ocaml that really allocates, and mutates state
<mcstar>
so it is understandable, that the 'a list needs to be specialized
andreypopp has joined #ocaml
<mcstar>
also, this specific example seems to be not working in haskell
<mcstar>
ill probably harrass #haskell
gnuvince has quit [Ping timeout: 245 seconds]
Yoric has quit [Remote host closed the connection]
ggherdov has joined #ocaml
osa1 has quit [Quit: Konversation terminated!]
ftrvxmtrx has quit [Ping timeout: 272 seconds]
err404 has quit [Quit: Ex-Chat]
jamii has quit [Read error: Connection reset by peer]
ftrvxmtrx has joined #ocaml
gnuvince has joined #ocaml
andreypopp has quit [Quit: Computer has gone to sleep.]
<alex-hu>
/join #haskell
<alex-hu>
/join #haskell
<alex-hu>
sorry
<Hodapp>
NO!
<mcstar>
haha a convert
<alex-hu>
Somehow xchat only accepts join in the server window :-\
<_habnabit>
you had a leading space
<mcstar>
alex-hu: space
<alex-hu>
mcstar, How could that thing (asked on #haskell) be done in ocaml?
<alex-hu>
mcstar, as for "what's wrong", actually, nothing --- I prefer ocaml for any practical projects, but I'm also learning haskell
<mcstar>
alex-hu: memory mapped files?
<alex-hu>
yes
<alex-hu>
I know it's done with bigarray module, but it doesn't resolve the dilemma I have.
<mcstar>
im know more haskell than ocaml, but not very much either
<alex-hu>
Unless the array itself were put in a separate file, which is not always practical.
<mcstar>
btw im hungarian too
<alex-hu>
The question I have is how could I access data (array of doubles) from a memory-mapped file with header (specifying some meta-data) without reading the whole array into memory?
<alex-hu>
The array itself is quite big (more than ram available).
Sablier has quit [Read error: Connection reset by peer]
<alex-hu>
mcstar, I think this problem is easier to solve in haskell, btw
<mfp>
alex-hu: the file being mmaped doesn't mean that it's actually read from disk
<alex-hu>
mfp, I understand very well how mmap() works.
<mfp>
there's no pb with it being larger than the RAM you have as long as your address space is large enough (i.e. 64-bit) and your *working set* fits
<mfp>
sorry then, it seems I misunderstood this > without reading the whole array into memory?
<alex-hu>
mfp, But how could I do what I want (accessing values in an array which is a part of a binary data file with header) in ocaml?
<alex-hu>
You could ignore the "without reading..." part --- I just didn't see how could I approach this problem without reading from stream, which is lame.
<mfp>
I don't know if bitstring allows to work on mmap'ed files, though
<alex-hu>
i think it doesn't
<alex-hu>
I checked it out once. A good thing, actually.
<mcstar>
alex-hu: "The optional pos parameter is the byte offset in the file of the data being mapped;" from the bigarray doc
<mcstar>
so if you have a header in that file, you could set pos to that size i believe
<alex-hu>
mcstar, but how would I access the file to parse the header before that? Just use an ordinary stream interface?
<mcstar>
probably, id do that
<alex-hu>
mcstar, Ok, that might work. Thx.
<alex-hu>
mcstar, what about a more complex problem: we need to map multiple arrays in a single file?
<mcstar>
alex-hu: im sure you know about the tools available to ocaml more than me, i was just giving some general advice
<alex-hu>
mcstar, In principle, I could use the same handle and different offsets, right?
<mcstar>
know more*
<mcstar>
depends on the layout of the array
emmanuelux has quit [Read error: No route to host]