<alexyk>
how do I export a type from a module? I use the type defined in a module in a file which links with it, and can't see record labels
<alexyk>
I have a record type used by a module; then I need to use it in the main calling module's functions. How do I reuse it except copying -- which works?
<jonafan>
open ModuleName?
<alexyk>
and if I don't want to import all names and refer to functions as Module.funname?
<alexyk>
doing type = Module.type doesn't bring record fields into scope
<jonafan>
you could rename the module as something short
<jonafan>
module M = Module;;
sporkmonger has joined #ocaml
<alexyk>
jonafan: doesnt' get the record type in
<jonafan>
yeah, i don't think there's a way to import just the record type
<jonafan>
but this is slightly nicer
<jonafan>
{M.id = blah; M.name = "blah"}
<kaustuv>
If you want to refer to the field f of type M.t as f, you have to write:
<kaustuv>
type somename = M.t = <copy definition of M.t>
* jonafan
wrong again
<alexyk>
kaustuv: it only checks consistency, not avoiding copy?
<jonafan>
if you copy, i don't think the records created in that file will be interchangable with the ones from the other file
<kaustuv>
They will be fully interchangable as long as you have the proper manifest type (= M.t)
<alexyk>
kaustuv: works; I've tried type t = M.t and it also works, so copying = {...} just brings fields in scope... no shorter way?
<kaustuv>
The best way, as far as I know, to use record fields is just to use M.f to refer to field f defined in a type in M. It avoids the most problems at the cost of a few keystrokes. Use a short module synonym as jonafan suggested if the full name is annoying to type out.
<kaustuv>
(Remember that you can use let module M = LongModuleName in ...)
sporkmonger has quit []
slash_ has quit ["leaving"]
angerman has joined #ocaml
angerman_ has joined #ocaml
angerman has quit [Connection timed out]
arquebus has joined #ocaml
arquebus has quit [Read error: 104 (Connection reset by peer)]
Yoric[DT] has quit ["Ex-Chat"]
alexyk has quit [Read error: 110 (Connection timed out)]
alexyk has joined #ocaml
<alexyk>
what's an efficient way to fold over array with index?
<alexyk>
i.e. foldli: ('a -> int -> 'b -> 'a) -> 'a -> 'b array -> 'a
coastermaster has joined #ocaml
vuln has joined #ocaml
<vuln>
Hi everybody. I'm trying to compile a code in Ocaml to native machine code but it keeps telling me 'segmentation fault', even though when I compile to Bytecode it yells nothing
<vuln>
Am I doing anything wrong?
naufraghi has joined #ocaml
yziquel has joined #ocaml
naufraghi has left #ocaml []
<vuln>
humm..
jeremiah has quit [Read error: 104 (Connection reset by peer)]
<yziquel>
anyone knows of a library to produce graphs? (in the sense of plotting 2D graphs, not in the sense of a graph data structure...)
alexyk has quit []
Ched has quit [Read error: 110 (Connection timed out)]
Ched has joined #ocaml
jeremiah has joined #ocaml
<vuln>
Hi everybody. I'm trying to compile a code in Ocaml to native machine code but it keeps telling me 'segmentation fault', even though when I compile to Bytecode it yells nothing
<vuln>
Am I doing anything wrong?
<det>
You have to give more information than that
<vuln>
det: I wrote a code with just ONE line: print_int 2;;
<det>
Such as command the command line that is giving you the segfault
<vuln>
Of course it works at toptool, and compiling as bytecode.
<vuln>
But when I use ocamlopt it just yells seg fault
<thelema>
hmm... I wonder if there's some wierd permissions problem... does xandros have any wierd in-kernel security modules?
<vuln>
Unfortunatly, I don't know :(
<vuln>
I don't even like XandrOS, I'm just waiting my computer back to install other OS in Eee PC and don't get worried about compatibility/wifi support
<vuln>
But I've read somewhere else about the same problem in Debian
<thelema>
it looks like it's failing to do a readlink: #
<AxleLonghorn>
Check out the compiler-error at the bottom
<AxleLonghorn>
why wont "Graph.Dot_ast.id * 'a" unify to "Graph.Dot_ast.node_id" when Graph.Dot_ast contains "type node_id = id * port option"
<thelema>
Builder.G.V.label != string?
<AxleLonghorn>
it does
<AxleLonghorn>
"module Generic(G : Graph.Sig.IM with type V.label = string and type E.label = string) = struct ..." is the module in which the pasted code rests
<thelema>
ah, your problem is the second argument - you're working with an attr, and you need to work with an attr list
<AxleLonghorn>
(Graph.Dot_ast.id * Graph.Dot_ast.id option) list
<AxleLonghorn>
compared with Graph.Dot_ast.attr list
<thelema>
yes
<thelema>
is different
<AxleLonghorn>
why?
<AxleLonghorn>
they're both lists, and Dot_ast.attr = (id * id option) list
<thelema>
the second is (Graph.Dot_ast.id * Graph.Dot_ast.id option) list list
<thelema>
attr list = (id * id option) list list
<AxleLonghorn>
so I need to make my second argument take a list of lists
<thelema>
yes
<AxleLonghorn>
weird
<thelema>
got me why, but that's the interface
<AxleLonghorn>
yeah, that's really odd
<thelema>
a list of attrs, each of which is already a list...
<thelema>
maybe so you wouldn't have to flatten
<AxleLonghorn>
I don't understand
<thelema>
you = caller of function
<thelema>
it takes work to flatten a list of lists into a list.
<thelema>
much less work to make a list than to concatenate
Snark has joined #ocaml
<thelema>
when given a bunch of lists
wsmith84 has joined #ocaml
<AxleLonghorn>
well, thank you a lot
<AxleLonghorn>
it works now
coastermaster has joined #ocaml
<thelema>
n/p
coastermaster has quit [Client Quit]
palomer has joined #ocaml
<sanguinev>
Is there a simple (i.e. without regex) ocaml function to determine if a string contains another string as a substring? (Boolean or index output is fine)?
<thelema>
batteries, yes. stdlib... I'll have to check
<thelema>
not in stdlib - only character searching functions, no string searches
<sanguinev>
thelema: Damn, that's what I knew existed, was hoping there was a string one. Time to implement what I need explicitly I guess.
|jedai| has quit [Read error: 110 (Connection timed out)]
<flux>
for me the topmost annoyance I can think of in the current syntax is the problem with nested matches
<flux>
other than that.. it's ok :)
<flux>
also I'm not convinced the fix the revised syntax gives is all that great
<kaustuv>
nested matches are no problem if you always use begin ... end around inner matches. Too bad the revised syntax forbids begin ... end.
<bjorkintosh>
you can stick them into comments.
<flux>
but the compiler will not check them then, will it?-)
<bjorkintosh>
but programmers are smart, aren't they?
<kaustuv>
have you *met* any programmers?
<bjorkintosh>
they can create begin/end-in-comment pre-processors can't they? :D
jeremiah has quit [Read error: 104 (Connection reset by peer)]
<bjorkintosh>
sure i have. they're full of themselves.
<flux>
we're on #ocaml. we know programmers aren't perfect, and we like to work with the compiler to attain perfectness :)
<tsuyoshi>
perfection, you mean
jeremiah has joined #ocaml
<bjorkintosh>
so why was the new syntax introduced if you guys don't like it?
bzzbzz has joined #ocaml
l_a_m has quit ["Lost terminal"]
slash_ has joined #ocaml
l_a_m has joined #ocaml
<flux>
perhaps someone else did like it?
<flux>
it does have higher internal concistency
<flux>
I wonder if I would mind had I begun with the revised syntax
<flux>
or would I find the old syntax bad..
<th5>
regardless of which is better - having two different syntaxes is too much of a burden - i'm not crazy about revised syntax but even if i was, any gains it gives are so outweighed by fragmenting the limited examples and documentation out there
<bjorkintosh>
so i'm new to the game... does it mean the old examples are broken completely for the current o'caml compiler?
<flux>
the new syntax is in its own syntax module
<flux>
so no, by default you can compile old examples just fine
<th5>
bjorkintosh: don't worry about revised syntax at all - they didn't change the syntax - someone made an alternative syntax to the standard - mostly comes up when reading about camlp4 (the whole camlp5 manual in this revised syntax)
Spiwack has joined #ocaml
filp has quit [Read error: 54 (Connection reset by peer)]
sporkmonger has joined #ocaml
aryx has left #ocaml []
filp has joined #ocaml
|jedai| has joined #ocaml
willb has joined #ocaml
rwmjones_ has joined #ocaml
|jedai| has quit [Read error: 110 (Connection timed out)]
willb has quit [Read error: 110 (Connection timed out)]
|jedai| has joined #ocaml
angerman has quit []
Ched has quit [Remote closed the connection]
Ched has joined #ocaml
joelr1 has joined #ocaml
<joelr1>
good day folks
<joelr1>
can you use ocamllex with a camlp4 parser?
<mrvn>
How would you represent a struct of C function pointers that may be NULL?
<mrvn>
Should default to NULL too.
<joelr1>
opt
<joelr1>
opt struct
<th5>
thats what i was thinking
<joelr1>
sorry, struct option
<mrvn>
record of closure options?
<mrvn>
The function pointers can be NULL. the struct must be there.
<mrvn>
The option type means another indirection in the stubs code, right?
<mrvn>
HOW are options actualy represented. Can't find it in the docs.
<vuln>
I'm trying to compile my Ocaml packages, but it asks me for a -host option. I use GNU/Linux i686 (XandrOS) in a Eee PC
<vuln>
What am I supposed to set as -host?
<Camarade_Tux>
it's weird you have to set anything...
<olegfink>
i686-linux-gnu should do.
<vuln>
Thank you very much.
* Camarade_Tux
wonders if there's not another, underlying, problem
<vuln>
it doesn't work :(
<olegfink>
vuln: are you speaking about ocaml's configure script?
<vuln>
olegfink: yes :)
<tab>
mrvn: forgot i had a define .. Val_none being Val_int(0)
<mrvn>
So I can use option types. But how do I make them default to None?
<olegfink>
vuln: try running config/gnu/config.guess and see what it says
<mrvn>
tab: Camarade_Tux code has it.
<olegfink>
(it's used in the configure script, so if it asks for -host, config.guess has failed)
<vuln>
i686-pc-linux-gnu
<tab>
mrvn: to have them set to None you just need to set them to Val_none in your C code
<vuln>
Oh, the files was -x
<vuln>
Invalid configuration `linux-gnu': machine `linux-gnu' not recognized
<vuln>
Please specify the correct host type with the -host option
<olegfink>
vuln: so does chmodding help?
<vuln>
I did it already and it now gives me that message
<vuln>
I show above
<olegfink>
do you use -host?
<vuln>
Yes.
<olegfink>
try without it.
<mrvn>
tab: They are created by the user. I don't want them to have to list 30 name=None; fields when they don't set the callback.
<vuln>
OH
<vuln>
Now it works.
<vuln>
I wrote i686-pc-linux-gnu in the configure file in host variable.
<vuln>
thelema: hi :)
<olegfink>
you don't have to, it asks config.guess.
<th5>
mrvn: just make it an optional parameter with the default to None
<mrvn>
th5: let ops = { foo=None; bar=None; baz=None; .... 30 more }
<mrvn>
But I know what I can do. I an export a default_ops and users can use let ops = { default_ops with foo = Some fn; }
<mrvn>
s/an/can/
<vuln>
olegfink: A file named unix.c is supposed to be in the asmrun/ directory?
angerman has joined #ocaml
<th5>
mrvn: yeah so make a function that is your "constructor" - takes in 30 optional params and returns a struct
<mrvn>
th5: whats wrong with the "default_ops with ...?
<th5>
looks fine too
willb has joined #ocaml
<th5>
whatever works
<th5>
ive never tried to use C code with ocaml so dont listen to me anyway
<Camarade_Tux>
mrvn, which library are you trying to bind ?
<vuln>
olegfink: make[2]: *** [pervasives.cmi] Falha de segmentação
<vuln>
make[2]: Saindo do diretório `/home/user/ocaml-3.11.0/stdlib'
<vuln>
make[1]: ** [coldstart] Erro 2
<mrvn>
libfuse
<vuln>
:(
<vuln>
(it happened when I was doing make world)
<Camarade_Tux>
mrvn, if you have a record, you can use the 'with' extension like 'with default_params' :)
<olegfink>
vuln: could you post some more backlog somewhere? and no, unix.c isn't in asmrun/ for me
<Camarade_Tux>
mrvn, ok, I was just asking because "callback" sounded like you could have been binding some gtk app for which I have an automatic binder
<mrvn>
Camarade_Tux: scroll a few lines up. Thought of that too.
kaustuv has left #ocaml []
<Camarade_Tux>
right
<mrvn>
Camarade_Tux: Any idea how to get around the options?
<vuln>
olegfink: thanks.
<vuln>
olegfink: a sec
<Camarade_Tux>
none beside what th5 suggested (using a function with optional params to construct the record)
<mrvn>
Camarade_Tux: I ment in the representation
<mrvn>
I guess I could use (Obj.magic 0) as default value.
<olegfink>
vuln: er? I mean like, in a hello world test?
<vuln>
olegfink: I don't get what you mean
<mrvn>
ocamlopt -I ../lib -o fs fuse.cmxa fs.ml
<mrvn>
../lib/fuse.a(fuse.o): In function `camlFuse__fuse_forget_284':
<mrvn>
(.text+0x318): undefined reference to `caml_fuse_reply_none_stub'
<mrvn>
Now I need to write all the missing stubs.
<olegfink>
vuln: can you compile a runnable binary with gcc?
<vuln>
olegfink: of course
<vuln>
I write codes in C and it never gave me a problem
<olegfink>
vuln: then you could file a bug report/try debugging ocamlrun
ttamttam has joined #ocaml
<mrvn>
Why does ocamlopt complain about caml_fuse_reply_none_stub though? The camlFuse__fuse_forget_284 function is not referenced by fs.ml. Shouldn't that get thrown out completly?
wsmith84 has quit [Read error: 110 (Connection timed out)]
vuln has quit ["leaving"]
slash_ has quit [calvino.freenode.net irc.freenode.net]
jlouis has quit [calvino.freenode.net irc.freenode.net]
Stefan_vK has quit [calvino.freenode.net irc.freenode.net]
mfp has quit [calvino.freenode.net irc.freenode.net]
maxote has quit [calvino.freenode.net irc.freenode.net]
mr_uggla has quit [calvino.freenode.net irc.freenode.net]
gildor has quit [calvino.freenode.net irc.freenode.net]
kg4qxk has quit [calvino.freenode.net irc.freenode.net]
bohanlon has quit [calvino.freenode.net irc.freenode.net]
mr_uggla has joined #ocaml
slash_ has joined #ocaml
jlouis has joined #ocaml
Stefan_vK has joined #ocaml
mfp has joined #ocaml
maxote has joined #ocaml
bohanlon has joined #ocaml
gildor has joined #ocaml
kg4qxk has joined #ocaml
kaustuv has joined #ocaml
s4tan has quit []
_zack has quit ["Leaving."]
ttamttam has left #ocaml []
angerman has quit []
ched_ has joined #ocaml
itewsh has joined #ocaml
Ched has quit [Read error: 110 (Connection timed out)]
sporkmonger_ has joined #ocaml
ttamttam has joined #ocaml
alexyk has joined #ocaml
jeremiah has quit [Read error: 104 (Connection reset by peer)]
filp has quit ["Bye"]
alexyk has quit []
sporkmonger has quit [Read error: 110 (Connection timed out)]
ttamttam has left #ocaml []
jeremiah has joined #ocaml
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
Snark has quit ["Ex-Chat"]
ilor has joined #ocaml
jeremiah has quit [Read error: 104 (Connection reset by peer)]
alexyk has joined #ocaml
alexyk has quit [Client Quit]
itewsh has quit [Read error: 110 (Connection timed out)]
Spiwack has quit ["Leaving"]
itewsh has joined #ocaml
Amorphous has quit [Read error: 110 (Connection timed out)]
Morphous has joined #ocaml
Alpounet has joined #ocaml
jeremiah has joined #ocaml
rwmjones_ has quit ["Closed connection"]
Alpounet has quit ["Quitte"]
<ehird>
Can you do #use "topfind" without the help blurb?
sgnb has quit [Read error: 104 (Connection reset by peer)]
sgnb has joined #ocaml
Yoric[DT] has joined #ocaml
^authentic has joined #ocaml
thelema has quit [Read error: 110 (Connection timed out)]
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
<ehird>
When building batteries...
<ehird>
> File "src/libs/compilers/compilers.ml", line 1, characters 0-1:
<ehird>
> Error: Could not find the .cmi file for interface
<ehird>
> src/libs/compilers/compilers.mli.
weechat2 has joined #ocaml
<mfp>
ehird: batteries' toplevel does it this way: let interactive = !Sys.interactive;; Sys.interactive := false;; #use "topfind";; .... Sys.interactive := interactive;;
<ehird>
heh
wsmith84 has joined #ocaml
chicco has quit [Read error: 111 (Connection refused)]
authentic has quit [Read error: 110 (Connection timed out)]
^authentic is now known as authentic
naufraghi has quit [Read error: 110 (Connection timed out)]
^authentic has joined #ocaml
authentic has quit [Read error: 60 (Operation timed out)]
^authentic is now known as authentic
itewsh has quit [Read error: 110 (Connection timed out)]
itewsh has joined #ocaml
jlouis has quit ["Lost terminal"]
ttamttam has joined #ocaml
<ehird>
hmmmmmm
<ehird>
I think the issue is Compilers.mli vs compilers.mli
<ehird>
case
<ehird>
it's compilers.ml but Compilers.mli
Alpounet has joined #ocaml
itewsh has quit [Read error: 145 (Connection timed out)]
chupish has joined #ocaml
itewsh has joined #ocaml
Alpounet has quit [Remote closed the connection]
<Yoric[DT]>
ehird: arf, I believe that's fixed in the git
<ehird>
>___<
<ehird>
I'm using godi
rwmjones_ has joined #ocaml
rwmjones has quit [Read error: 110 (Connection timed out)]
itewsh has quit [Read error: 60 (Operation timed out)]
itewsh has joined #ocaml
sporkmonger_ is now known as sporkmonger
alexyk has joined #ocaml
itewsh has quit [Connection timed out]
itewsh has joined #ocaml
m3ga has joined #ocaml
<itewsh>
what's the best way to make a list from the standard input?
thelema has joined #ocaml
<itewsh>
I do this : Array.init n (fun _ -> Scanf.scanf "%d " (fun x -> x)) for arrays, but for a list?