<dfranke_laptop>
Hi, I'm trying to get started with Ocaml but the site seems to be down. Would someone mind emailing/DCCing me a PDF of the reference manual?
<dfranke_laptop>
or pointing me to a mirror?
<zmdkrbou>
if you're using linux you can get the doc on your computer
<zmdkrbou>
(i mean with the package)
<dfranke_laptop>
hmm, is there a Debian package I need other than ocaml?
<dfranke_laptop>
all I see in /usr/share/doc/ocaml is a readme and changelog and some Tk examples.
<dylan>
ocaml-doc?
<zmdkrbou>
do you have /usr/share/doc/ocaml-doc-3.09/html/ ?
<dfranke_laptop>
Package ocaml-doc is not available, but is referred to by another package.
<dfranke_laptop>
This may mean that the package is missing, has been obsoleted, or
<dfranke_laptop>
is only available from another source
<dfranke_laptop>
and no, I don't.
<dylan>
using etch?
<dfranke_laptop>
yes
<dylan>
That explains it.
<dylan>
(I also bet you're using amd64)
<dfranke_laptop>
no, x86
<dylan>
Oh. wow, etch is screwed up there too?
<dylan>
ocaml-doc exists in stable and unstable. so, um...
<StyxAlso>
I'm trying to define a function that rotates a point about another point
<StyxAlso>
The compiler complains about line 12
<StyxAlso>
I'm using this problem to try to learn about ocaml, so I'm not very knowledgeable about the language yet
<StyxAlso>
I've been a python programmer for years, but that's not helping ;)
<sponge45>
It seems that you are mixing ints and floats...
<StyxAlso>
I want the result of the rotation to be an integer x component and an integer y component
<StyxAlso>
cos() and sin() return floats, and the distance is going to be a float
<StyxAlso>
I want to take r*cos(angle), for example, and truncate that to an integer
<sponge45>
truncate (r*.cos(angle))
<StyxAlso>
Heh, simple as that, is it? :)
<StyxAlso>
I was using int() which is the python way of doing things
<sponge45>
yeah, but it's *. not * <- !!!
<sponge45>
truncate is the same as int_of_float; it's not exactly what you should use if you have both negative and positive ints
<sponge45>
truncate (-0.5) = truncate 0.5
<StyxAlso>
So if I don't want to lose the sign, I use int_of_float?
<therp>
hm, "Error: You must specify an input file". Isn't "ocaml *.mlo" supposed to drop me into a top level repl that reads from stdin?
<sponge45>
you should use something like that: let round x = if x < 0. then truncate x - 1 else truncate x
<sponge45>
truncate and int_of_float *are* the same, but they are symmetric, which is not useful for rounding
<sponge45>
therp: ocaml file.ml just executes the given script
<sponge45>
you should use #use "file.ml" from the toplevel (not what you want)
<sponge45>
but you can do this by writing a .ocamlinit file (not very convenient either)
<sponge45>
I don't think there is way of doing this, but you can easily create a shell script which creates the .ocamlinit for you
<StyxAlso>
sponge45, Why is it that when I type truncate -1.0;; in the ocaml interpreter that I get an error?
<therp>
styxalso: truncate (-1.0);; ?
<sponge45>
It's like: pi-1.0 What do you think?
<StyxAlso>
Hmm, that works
<therp>
sponge45; I have multiple files, and also I don't want any script I just want to call the functions that are defined in all the *.mlo files. reading the man page of ocaml it should drop me into a repl when there are no scripts given, and "ocaml *.mlo" makes ocaml interpret all .mlo files as object files, hence no script. so I don't understand the error. The man page seems wrong.
<sponge45>
.mlo is an original suffix
<therp>
ah ok, the problem seems to be one object file called main.mlo. once this is removed it works. Ah tricky, loading main.mlo kills off ocaml's own top level reading routine, the error is actually from my own main.mlo not from ocaml
<pango>
*.mlo is expanded to the exhaustive list by the shell
<pango>
and ocaml only accepts on script -file name
* therp
.oO("remember: loading an object file containing main() does not work for /usr/bin/ocaml")
<pango>
object files are .cmo or .cma
<pango>
don't know what your .mlo are
<therp>
ah, thinkos. I meant cmo
<pango>
then there's no specific main () function in ocaml... modules contents are just evaluated in the order they're loaded
<therp>
still, same applies. the problem is that one cmo contains main() which seems to replace the main of /usr/bin/ocaml.
<therp>
hm, then it seems I should remove Exit
<sponge45>
You mean, it actually computes something which exits the program?
<sponge45>
:-)
<therp>
ok, another wrong mental model of object loading for ocaml rejected.
<StyxAlso>
sponge45, OK, now I'm having trouble with my rotate function
<sponge45>
you have to put parentheses sometimes...
<StyxAlso>
Where, exactly?
<pango>
around 1.0*.(2.0*pi)/3.0 ... and replace / with /. ;)
<pango>
and * with *.
<sponge45>
all operators have lower priority than function application
<sponge45>
this way you can write things like cos x + sin y
<therp>
may I ask my last noob question for today? How do I change Sys.argv when I'm inside the ocaml repl? Sys.argv := [|"foobar"|] or let Sys.argv = [|"foobar"|];; tried.
<sponge45>
but cos x +. y really means (cos x) +. y
<StyxAlso>
Ah, that fixed it
<StyxAlso>
How very odd
<sponge45>
You can't change Sys.argv. Why would you do that?
<therp>
sponge45: to do things like: "ocaml support.cmo", #trace fun, set Sys.argv to some input file for the following, #use main.cmo, that processes argvs.
<therp>
I just don't want to rewrite main.ml, because I have 20 other main.ml of that kind. so maybe there is a way to trick main.ml into thinking it's loaded with proper argvs instead of the ocaml argv that are pointing to my object file list.
<sponge45>
I don't know, I don't really work like that
<therp>
admitted, this is rather hacking than working.
<sponge45>
if you want to test a module, create a function which processes an array which is meant to be Sys.argv
<sponge45>
in main.ml, you can do this: let _ = if Sys.interactive then run Sys.argv
<mellum>
You can't change arrays, since they don't use indirection, Sys.argv points directly to the data internally
<sponge45>
where "run" is the function I was talking about
<pango>
if not !Sys.interactive I think
<sponge45>
actually i meant "if not (Sys.interactive)", but you get it
<sponge45>
yes
<therp>
yes, that'd be ok, but $ find -name "main.ml" | wc yields 29 main.ml files. actually I'm investigating the code from http://www.cis.upenn.edu/~bcpierce/tapl/ - a book on type systems with the implementations all written in ocaml.
<sponge45>
why not just compile the whole programs and run them with the arguments you like?
<sponge45>
sure you don't get the toplevel facility
<therp>
sponge45: I'm would like to trace the recon function (it's in core.ml) to get a better understanding of what it's doing. I thought #trace Core.recon;; would have helped me in the repl
<sponge45>
you can make a custom toplevel very easily with OCamlMakefile, by the way. But you shouldn't include the main.ml, or change it like mentioned above
<sponge45>
for tracing, I use printf
<therp>
I'll find a way I think. anyway thanks guys, very helpful, nice channel attitude.
sponge45 has quit ["nighty night"]
<pango>
if he always uses the Arg module... that one has a parse function, but also a parse_argv function that can take an arbitrary string array
<pango>
so the minimal modification would be 1. create a global array string ref at the beginning of main.ml, say let my_args = ref [||] and 2. replace Arg.parse with Arg.parse_argv !my_args
<pango>
then you can set my_args to any value before calling the main function...
<therp>
thanks, will try that
<StyxAlso>
Anyone familiar with the Graphics module in Ocaml?
<pango>
therp: (of course it would be cleaner if the main function took a string array argument... but depending on how main.ml is written, that could require more work...)
<therp>
hm #trace seems to like printing <abstr> instead of the arguments.
pango has quit ["brb"]
pango has joined #ocaml
love-pingoo has joined #ocaml
Revision17 has joined #ocaml
revision17_ has quit [Read error: 110 (Connection timed out)]
<pango>
another reason could be that he abstract types outside their module... I don't think the toplevel can "see thru" abstract types, maybe only the debugger can
<pango>
installable printers could help there too, but they will need to be defined in the same module as the type they pretty-print, to have access to the concrete type...
<pango>
(I don't use #trace much either)
Snark has joined #ocaml
<fluxx>
hmm.. there are some extensions though that can generate printers for you, aren't there?
<dark_light>
so it seems useless to a telnet server..
<dark_light>
is it ok to wait a data with select and read it as a in_channel?
pango has quit [Remote closed the connection]
pango has joined #ocaml
<fluxx>
I don't think it is
<fluxx>
there might be unread data in the channel while the socket itself is non-empty
<fluxx>
so unless there is a function to check for pending data in in_channel don't do it (there might be, I don't remember ;-))
<dark_light>
i think i must rewrite the read_line for file_descrs, and this is something i was trying to avoid
<dark_light>
treat sockets as channels is so more easy :(
<dark_light>
i think select at least will make sharing data a lot easy
<dark_light>
there are so many dilemas at the middle game (something i heard playing chess..), it's true in programming too..
mnemonic has quit ["leaving"]
slipstream has joined #ocaml
slipstream-- has quit [Read error: 104 (Connection reset by peer)]
love-pingoo has joined #ocaml
mnemonic has joined #ocaml
finelemo1 has joined #ocaml
<mnemonic>
re
rillig has joined #ocaml
gim has joined #ocaml
finelemo1 has quit [Read error: 110 (Connection timed out)]
finelemo1 has joined #ocaml
finelemon has quit [Read error: 110 (Connection timed out)]
smimou has joined #ocaml
pango has quit ["Leaving"]
pango has joined #ocaml
ketty has quit [Read error: 110 (Connection timed out)]
ketty has joined #ocaml
pango has quit [Read error: 104 (Connection reset by peer)]
pango has joined #ocaml
chessguy has joined #ocaml
chessguy2 has joined #ocaml
mikeX has quit [Read error: 104 (Connection reset by peer)]
chessguy2 has quit [Client Quit]
chessguy has quit [No route to host]
rillig has quit [Read error: 110 (Connection timed out)]
bzzbzz has joined #ocaml
love-pingoo has quit ["Connection reset by pear"]
mnemonic_ has joined #ocaml
mnemonic_ has quit [Client Quit]
mnemonic has quit [Connection timed out]
smimou has quit ["bli"]
therp has quit [Read error: 113 (No route to host)]
rillig has joined #ocaml
BetaTEST has joined #ocaml
<BetaTEST>
hello. could you tell me why "[< >];;" leads to syntax error?
<dylan>
without camlp4, that isn't valid syntax, is it?
<BetaTEST>
i don't know :) how do i use camlp4?
<dylan>
it's beyond being easy to explain in IRC. try the caml site. :)
<BetaTEST>
the problem is, in Caml Light everything's okay. but in OCaml something should be turned on probably
<BetaTEST>
well, ocaml manual just says it's extension, nothing more
<dylan>
#load "camlp4o.cma";;
<dylan>
^^ simple answer
<BetaTEST>
yeah, that's it :)
<BetaTEST>
thanks )
<dark_light>
the module Event don't works for inter-process communication. right?
Revision17 has quit ["Ex-Chat"]
<BetaTEST>
oh... looks like parsing with streams improved... expressions like let rec integer n = function
<BetaTEST>
oh :)
<BetaTEST>
[< ' `0`..`9` as c; (integer (10*n + int_of_digit c)) r >] -> r <-- that's it. it's unreadable (to me). is "[< ''0'..'9' as c; rest >] -> integer (10*n + int_of_digit c) rest" equivalent (and readable) construction in ocaml?
<BetaTEST>
previous one was written in caml light
Bigb[a]ng is now known as Bigbang
<Smerdyakov>
dark_light, not directly. You can create events for inter-process operations, though.
<Smerdyakov>
dark_light, they won't be able to exchange values in the same nice way you get among threads sharing a garbage-collected heap./
<dark_light>
and the inter-process operations uses what? i have to use unix sockets? is there anything like d-bus on ocaml?
<dark_light>
the ocaml gc works better with threads? hmm
<Smerdyakov>
Events allow you wide freedom in packaging any operation you like.
<Smerdyakov>
You can't share a heap across processes; it's not a question of "works better," but rather "works at all."
<dark_light>
hmmm. but what about the dbus?
<Smerdyakov>
I don't know what that is.
<dark_light>
well, me either, i only know that dbus is a type of IPC and works better than unix sockets
<Smerdyakov>
Concurrent ML is a nice interface that works with _any_ communication method.
<BetaTEST>
is there any paste service? i have some strange problem with streams...
<dark_light>
BetaTEST, well, pastebin.com ?
<dark_light>
rafb.net/paste
<dark_light>
maybe i am too lazy to study better something, but i am trying to build a server for a lot of days and still don't get what's better for sharing things, fork+ipc, thread+event or select+simply use variables
<Smerdyakov>
dark_light, threads. Next question?
<dark_light>
eheheheheh
<dark_light>
But but but :(
<dark_light>
Smerdyakov, someone said me that fork would lead to a better/more scalable/etc design
<Smerdyakov>
I think that limitations in the OCaml implementation mean that you can't take advantage of multiple processors/cores using just threads. Was that the motivation for this person's suggestion?
<dark_light>
no, that person said about a generic programming way to do
<Smerdyakov>
Sorry, I don't understand what you just said.
<dark_light>
Hmmmm. that person said a thing applicable to any language..,
<dark_light>
one server to store data, that communicates with each connection (that is a forked server)
<dark_light>
Smerdyakov, what's the problem with select? (is thread generally faster than select, for a server..?)
<Smerdyakov>
Programming with threads is usually easier than programming with select.
<dark_light>
*easier* ?
<dark_light>
i just though that select would make sharing data a lot easy
<dark_light>
because i can access things directly, without any abstraction
<Smerdyakov>
I don't understand. Why can't you do that with threads?
<dark_light>
well, i have to use mutex when i modify anything
<dark_light>
and use conditions
<Smerdyakov>
No. Concurrent ML (Event) involves no mutexes.
<dark_light>
to tell another thread that it can write while i am writing
<dark_light>
Hmmmmm
<dark_light>
but event is another layer of abstraction