solidus-river has quit [Ping timeout: 252 seconds]
solidus-river has joined #ocaml
Tobu has quit [Ping timeout: 272 seconds]
ocp has joined #ocaml
mehdid_ is now known as mehdid
Tobu has joined #ocaml
bacam_ is now known as bacam
Submarine has quit [Ping timeout: 240 seconds]
<Ptival>
thomasga: do you know about fixing typerex indentation?
<thomasga>
well it depends
<thomasga>
the easiest way is to update tools/ocp-typerex-ide/emacs/typerex-tuareg.el
<thomasga>
with the latest version of tuareg
<Ptival>
ok I'll take a look if needed
<Ptival>
I'm basically over-parens-ing my code to make the indentation behave properly :d
<thomasga>
the cleanest way is that I find some time to integrate my indenter with typerex
eni has joined #ocaml
<thomasga>
but I really don't know when I will be able to do that :-(
Tobu has quit [Ping timeout: 272 seconds]
ocp has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
gnuvince has quit [Quit: C-x C-c]
sivoais_ has quit [Quit: leaving]
sivoais has joined #ocaml
oriba has joined #ocaml
ocp has joined #ocaml
gnuvince has joined #ocaml
roha has quit [Read error: Operation timed out]
roha has joined #ocaml
mononofu has quit [Remote host closed the connection]
ankit9 has quit [Ping timeout: 260 seconds]
<mrvn>
I had some problems with tuareg and named arguments. After I used some of them the indent stopped working after that line.
<mrvn>
Anyone had that before?
oriba has quit [Quit: oriba]
<ssbr_>
Hum. How do I get more information about an exception? When I run this program, I get `Fatal error: exception Sys_error("Is a directory")`, but no information about where this occurs (or what was a directory.)
<ocp>
in this case, you cannot do nothing
<ssbr_>
_habnabit: Gah!
<ssbr_>
_habnabit: it was OCAMLRUNPARAM="b1" :(
<ocp>
your program has already caught the exception
<ssbr_>
not "b"
<ocp>
or maybe not actually ;-)
<ssbr_>
ocp: setting OCAMLRUNPARAM="b1: gave me the additional info `Raised at file "pervasives.ml", line 325, characters 12-32` :p
<ssbr_>
I should've googled then asked rather than asked then googled. :(
<mrvn>
compile with -g to get a backtrace
<ssbr_>
I assumed this'd be hard to google
<ocp>
beware that some program have a (try main () with e -> Printf.fprintf stderr "Fatal error: %s"......)
<mrvn>
You want the file+line that calles pervasives.ml
<ocp>
that prevents to know the location of the exception
<ssbr_>
mrvn: Ah.
<mrvn>
ocp: totaly useless and evil
<ocp>
you probably tried to seek into a directory
<adrien>
hmmm, iirc "try foo () with e -> ...; raise e" would give an "exception re-raised at"
<adrien>
no?
<mrvn>
adrien: but not the backtrace where it was originally raised
<mrvn>
iirc
<mrvn>
Would be nice if with -g exceptions would keep track of where they are raised, cought, reraised
<adrien>
I'm under the impression it's kept
<ssbr_>
I am trying to figure out where in the makefile to edit in a -g parameter :S
<adrien>
ssbr_: which makefile?
<mrvn>
adrien: maybe if you reraise the original instead of raising a new one.
<joelr>
thelema: i'm packing those modules into a library together with callbacks. callbacks refers to them Trade.t, etc., not as RAPI.Trade.t. and RAPI.mli does the same in the signatures for the missing modules
<joelr>
the library i'm packing is RAPI and i only provide RAPI.mli, no RAPI.ml
<thelema>
I don't think you can have a Callbacks base for a pack with code in it, anyone?
<thelema>
It looks like you're not building callbacks as a pack
<joelr>
thelema: what do you mean by a callbacks base for a pack?
<thelema>
packs have a base. Foo, Bar, Baz all become Base.Foo, Base.Bar, etc.
<thelema>
the base you seem to want for your callbacks pack is Callbacks
<joelr>
thelema: i get a circular build error now.
<joelr>
Circular build detected (src/RAPI.cmx already seen in [ src/Callbacks.cmx; src/RAPI.cmx; src/RAPI.cmxs ])
<thelema>
yes, ocamlbuild would give that... hmm...
ftrvxmtrx has joined #ocaml
<thelema>
ok, I don't know how to solve your problem and keep using packs.
<thelema>
from what I understand, to pack module Foo into Bar, you compile Foo with argument -for-pack Bar
<thelema>
and it creates Bar.Foo inside foo.cmx
<joelr>
right
<thelema>
and then you can join a bunch of these files into a single Bar.cmx by using -pack
<joelr>
the question is, should other modules in the pack be using Bar.Foo or just Foo?
<thelema>
but ocamlbuild and oasis seem to be creating bar.cmxa and putting the foo.cmx (-for-pack Bar) inside it.
<joelr>
gildor_: ^
<thelema>
I'm not certain. My understanding is that because of the -for-pack, it should be Bar.Foo
<joelr>
let me get a build log
<hcarty>
It should still be Foo.x
<thelema>
Obviously just Foo isn't working, although it only finds that out at link time because foo.cmi exists just fine and gives the interface information for Foo
<thelema>
oh... hmmm
<hcarty>
That works for me, but I'm using OCamlMakefile for that particular library
<thelema>
then maybe the problem is that Bar.cmx isn't being created?
<thelema>
and instead, bar.cmxa is being jumped to?
<joelr>
this is how it compiles callbacks, for example: ocamlfind ocamlopt -c -g -I src -ccopt -Wall -ccopt -W -ccopt -Wextra -ccopt -g -ccopt -x -ccopt c++ -ccopt -I -ccopt '~/Work/rithmic/5.2.0.0/include' -ccopt -g -package unix -package threads -package cmdliner -thread -for-pack RAPI -I src -o src/Callbacks.cmx src/Callbacks.ml
<thelema>
sure, and when does it create RAPI.cmx?
<hcarty>
joelr: Is there a ocamlfind ocamlopt -pack -o rAPI.cmx ...
<thelema>
I expect trade to be in RAPI.cma (as part of RAPI.cmo)
<ssbr_>
Hum. So I'm dealing with an ocaml app that takes the argument "-main_program" and runs it. (This is a datalog interpreter.) If -main_program isn't defined, it blows up, by assuming a default of "" (i.e. the current working directory -- not an executable file)
<joelr>
i think i know what the deal is. back in a few.
<thelema>
ssbr_: that sucks.
<ssbr_>
what would be the "right" way to enforce that there _is_ no default? Check if the parsed -main_program is the empty string and then if so, print an error message / the usage / argspec ? Or is there some way to make Arg do this for me?
<thelema>
afaik, Arg can't do this
<thelema>
after running Arg.parse, just do: if !main_program = "" then failwith "Need a -main_program"
<ssbr_>
So should I reproduce the behavior of raising Arg.Bad (except outside of Arg.parse) ?
<thelema>
ssbr_: yes, that would better; IIRC, you can call Arg.usage directly and then `exit 1`
<ssbr_>
thelema: OK, got it. Thanks for your help. :)
mononofu has joined #ocaml
thomasga1 has quit [Quit: Leaving.]
jave has quit [Read error: Operation timed out]
mononofu has quit [Remote host closed the connection]
mononofu has joined #ocaml
<ssbr_>
Hey guys, I'm pretty new to ocaml (limited experience in Haskell and ATS), and I'm really struggling to figure out what the type signature for printf means. Can anyone tell me where to look? (signature is `('a, out_channel, unit) format -> 'a`)
<thelema>
ssbr_: it's magical
<thelema>
the compiler assigns a type to the format string
<thelema>
this type includes the information on what further parameters are needed and their types
<thelema>
so the -> 'a becomes something like -> int -> string -> unit
djcoin has quit [Quit: WeeChat 0.3.2]
<ssbr_>
thelema: Well. Uh.
<hcarty>
ssbr_: The magic happens at compile time. The format string is parsed and the appropriate types fall out of that.
<ssbr_>
Right.
<hcarty>
The 'raw' type indicates things like the return value of the call, where output goes, and maybe a few other items.
<hcarty>
When read out loud, the type is generally pronounced "ooo, spooky"
<ssbr_>
I think, for now, I'm gonna let this slide and declare it magic.
<Qrntz>
that's what it is!
<ssbr_>
but I'll keep this in mind and come back to it once I'm more comfortable
<ssbr_>
Qrntz: sure, but all magic can be understood in principle!
<ssbr_>
by declaring it magic I'm just saying "I don't wanna ;_;"
<thelema>
if you look at the type of this, it has "int -> string -> '_a" in the type
<Qrntz>
«any sufficiently advanced technology is indistinguishable from magic»
<thelema>
the "int" matches the %d and the "string" matches the %s
ulfdoz has joined #ocaml
<ssbr_>
Right.
<ssbr_>
the other ML descendent I used -- ATS -- I think did something similar, but I never looked at the type signature
<ssbr_>
(also it used tuples instead of varargs)
<Qrntz>
ats actually gets translated to C — I think it has less magical transformations to do
<ssbr_>
Qrntz: It still tries to be type-safe, though
<ssbr_>
(to the extreme: it adds dependent typing)
<Qrntz>
I know, I tried it too :-)
<ssbr_>
so in particular, it suffers the same problem of "well, what if the format string doesn't match the types of the passed parameters?"
<ssbr_>
and so it has to generate the type based on the format string magically
Tobu has quit [Ping timeout: 272 seconds]
<thelema>
yes, the ocaml compiler looks at the string and generates the right type
mononofu has quit [Remote host closed the connection]
mononofu has joined #ocaml
mononofu has quit [Remote host closed the connection]
Tobu has joined #ocaml
diego_diego has joined #ocaml
<joelr>
thelema, hcarty: the problem was with my use of the packed library outside of the library. i was using modules (callbacks) that were packed but not "exported"
<joelr>
thanks for your help!
<thelema>
joelr: you're welcome.
<hcarty>
joelr: You're welcome, glad you got it working
jave has joined #ocaml
srcerer has joined #ocaml
larhat has joined #ocaml
bjorkintosh has joined #ocaml
jarray52 has joined #ocaml
larhat has quit [Quit: Leaving.]
<jarray52>
Is there an easy fix for the following piece of code: let total=0;; for i=1 to 100 do let total=total+i done;;
<_habnabit>
let total = 100
<thelema>
let total = ref 0
<thelema>
total := !total + i
<jarray52>
I'm trying to increment total by i inside the for loop.
<bjorkintosh>
hmm. should you be using a for loop at all?
<jarray52>
on each iteration
<_habnabit>
(1 -- 100) |> fold (+) 0
<jarray52>
bjorkintosh: I realize this is not the functional paradigm, but I'm trying to learn the language and implementing simple functions in many different ways.
<thelema>
let total = ref 0 in for i = 1 to 100 do total := !total + i; done
<bjorkintosh>
ah alright jarray52.
<jarray52>
thelema: Thanks.
<jarray52>
I'm using the ocaml interpreter. Is there a way to get the previous line by typing the up arrow key or some other keystroke combination?
<jonafan>
total = 50*99 iirc
<thelema>
jonafan: rlwrap ocaml\
<thelema>
(without \)
<jonafan>
also to the other dude
<thelema>
jarray52: you too
<thelema>
:)
<jonafan>
from my .bashrc: alias oc='rlwrap -r -c -D 2 ocaml'
<jonafan>
actually it's 50*101
<thelema>
jonafan: yes, n(n+1)/2
<hcarty>
jarray52: It can take a bit more effort to get going, but utop is nice as well
<jarray52>
jonafan: yes.
<hcarty>
jarray52: utop is a customized toplevel with context-sensitive completion, editing support, and a few other goodies.
<jarray52>
hcarty: Are there other ocaml interpreters?
<hcarty>
jarray52: utop is still using the same underlying code as the official 'ocaml' binary
<hcarty>
jarray52: But it has been extended/modified to support more features and a friendlier out-of-the-box environment.
<jarray52>
hcarty: It doesn't seem to be in my distro's repository
<hcarty>
jarray52: I'm not sure if it's available anywhere other than compiling from source.
Tobu has quit [Ping timeout: 272 seconds]
<hcarty>
jarray52: You can use odb.ml to ease the build process, but that may be getting ahead of what you want to do at this point.
<jarray52>
hcarty: Is utop the only other interpreter for ocaml?
<jarray52>
hcarty: I'm just trying to learn the basics of the language.
<hcarty>
jarray52: If you just want to get started with language basics then try.ocamlpro.com is a good start, or using rlwrap + the ocaml binary that comes from your distribution
<bjorkintosh>
what's rlwrap?
<jarray52>
hcarty: Thanks. Now, I understand what jonafan was trying to tell me.
<jonafan>
rlwrap makes the arrow keys do what you want them to do in the ocaml repl, among other things
<jarray52>
jonafan: Thanks for the .bashrc alias.
diego_diego has quit [Quit: diego_diego]
pango has quit [Ping timeout: 272 seconds]
Tobu has joined #ocaml
pango has joined #ocaml
avsm has joined #ocaml
eni has joined #ocaml
Kakadu has quit [Quit: Konversation terminated!]
<ssbr_>
Would anyone recommend a source for learning camlp4?
<ssbr_>
(in particular I have to modify a parser written in it.)
<thelema>
ssbr_: camlp4 docs are crap, you may have to reverse engineer existing parsers
<ssbr_>
(/ with it. Not sure of distinctions.)
<ssbr_>
thelema: blaraagh.
<ssbr_>
I'll just settle for the scraps people leave up on their blogs then.
<joelr>
mrvn: ping
<thelema>
ssbr_: there officially is a wiki for it, iirc
<ssbr_>
Agh. Can someone explain to me what this line does? "let _ = (program : 'program Gram.Entry.t) in ..."
<joelr>
mrvn: i'm returning Int_val from C to mean a parameter-less constructor and the values seem to be cached on the ocaml side. have you seen anything like that? i always get the same value even though the printout on the c side shows different values
<thelema>
ssbr_: it asserts that program has type 'a Gram.Entry.t
<ssbr_>
It assigns _ to something, so that must have side effects, but... that looks like a type declaration? I'm pretty fuzzy here. I haven't seen this.
<ssbr_>
Oh.
<ssbr_>
thelema: could that have been done when program was first assigned? (up at `let program = Gram.Entry.mk "program"`)
<mrvn>
ssbr_: it casts program to the type and assigns it to _
<mrvn>
ssbr_: which should be a total NOP
<ssbr_>
Right.
<ssbr_>
OK, thank you both.
<mrvn>
joelr: don't you mean Val_int?
<thelema>
mrvn: no cast; :> is cast
<mrvn>
thelema: :> isn't exactly a cast
<mrvn>
ssbr_: One thing that statement does it fix the type of program
<mrvn>
ssbr_: maybe some artefact left over from fixing a type error where the author wanted to specify the type to get a better error
<mrvn>
the caml/mlvalue.h should declare the value type as something that doesn't silently get promoted from ints or longs.
<joelr>
mrvn: i'm an idiot
Submarine has joined #ocaml
Submarine has quit [Changing host]
Submarine has joined #ocaml
<joelr>
mrvn: thanks
<mrvn>
typedef struct { long tag : 1; long val : 31/63; } for example.
<ssbr_>
ARGH. OK -- how do I tell if a .ml file is generated by a camlp4 thing?
<ssbr_>
pretty sure I was reading the wrong file.
<mrvn>
.oO(you get an error if you forget it)
<ssbr_>
(make clean does not clean things up properly, sadly)
<thelema>
ssbr_: ml files on disk are generally pre-camlp4 modification