Anarchos has quit [Quit: Vision[0.9.7-H-090423]: i've been blurred!]
tmaedaZ is now known as tmaeda
enthymene has quit [Quit: brb, home]
tmaeda is now known as tmaedaZ
avsm has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
seafood has joined #ocaml
seafood has quit [Client Quit]
Drk-Sd has quit [Quit: Lost terminal]
Drk-Sd has joined #ocaml
orbitz has quit [Ping timeout: 264 seconds]
_unK has quit [Remote host closed the connection]
orbitz has joined #ocaml
seafood has joined #ocaml
seafood has quit [Client Quit]
Mr_Awesome has quit [Read error: Connection reset by peer]
Mr_Awesome has joined #ocaml
brooksbp_ has joined #ocaml
boscop has quit [Ping timeout: 258 seconds]
seafood has joined #ocaml
derdon has quit [Quit: derdon]
travisbrady has quit [Quit: travisbrady]
seafood has quit [Quit: seafood]
maskd has quit [Remote host closed the connection]
seafood has joined #ocaml
seafood has quit [Client Quit]
valross has joined #ocaml
krankkatze has quit [Ping timeout: 264 seconds]
avsm1 has joined #ocaml
avsm has quit [Ping timeout: 276 seconds]
Drk-Sd has quit [Quit: brb]
enthymene has joined #ocaml
seafood has joined #ocaml
seafood has quit [Client Quit]
Drk-Sd has joined #ocaml
enthymene is now known as enthymacs
thrasibule has joined #ocaml
noj has quit [Ping timeout: 248 seconds]
valross has quit [Remote host closed the connection]
seafood has joined #ocaml
LionMade1fLions has quit [Ping timeout: 245 seconds]
seafood has quit [Client Quit]
LionMadeOfLions has joined #ocaml
patronus has quit [Ping timeout: 245 seconds]
patronus has joined #ocaml
MrHeavy has joined #ocaml
<MrHeavy>
I'm trying to assign to an element of a multi-dimensional array created with Array.make_matrix
<MrHeavy>
I end up getting this error:
<MrHeavy>
Error: This expression has type 'a -> 'a array array but an expression was expected of type 'b array
<MrHeavy>
My syntax is just:
<MrHeavy>
somearray.(0).(0) <- 1
<flux>
mrheavy, maye you're missing an argument to make_matrix?
<MrHeavy>
flux: You're absolutely right, I never gave it the default value, so type inference had no idea it was supposed to be storing integers
<MrHeavy>
*facepalm*
<MrHeavy>
Thank you much
<flux>
mrheavy, actaully what type inferencing thought was that you has a partially applied function
<flux>
mrheavy, therefore it said 'has type 'a -> 'a array' (ie: give a value to get an array of that type)
<MrHeavy>
Aaaaaaah.
<MrHeavy>
I literally learned what I know of OCaml in about 3 1/2 hours for a job interview at a heavy OCaml shop, so I'm still making lots of extremely dumb mistakes. :)
<MrHeavy>
Thankfully, not a developer position.
enthymacs is now known as enthymene
<flux>
mrheavy, btw, if you happen to use emacs or vi, the compiler can give you back the types of any expression
<flux>
that can be useful when debugging typing related problems. or just for understanding code better.
<MrHeavy>
gVim user. Got a good link? :)
<flux>
sorry, no, an emacs user myself :)
<flux>
but afaik it can be done :)
<flux>
the system relies on parsing the output produced by ocamlc -dtypes (it produces an .annot file)
bzzbzz has quit [Quit: leaving]
ulfdoz has joined #ocaml
thrasibule has quit [Ping timeout: 248 seconds]
zhijie has joined #ocaml
orbitz has quit [Ping timeout: 246 seconds]
mutewit has quit [Ping timeout: 260 seconds]
ttamttam has joined #ocaml
ttamttam has quit [Quit: Leaving.]
seafood has joined #ocaml
<flux>
hmm.. I wonder what's broken in my batteries installation, open Batteries (and using List.enum) gives me: File "foo.ml", line 1, characters 0-1: Error: Error while linking foo.cmo: Reference to undefined global `Batteries'
enthymene has quit [Quit: brb]
<flux>
BatList etc work fine
Drk-Sd has quit [Quit: g2g]
orbitz has joined #ocaml
thrasibule has joined #ocaml
joewilliams is now known as joewilliams_away
ulfdoz has quit [Ping timeout: 276 seconds]
ygrek has joined #ocaml
pimmhogeling has joined #ocaml
f[x] has joined #ocaml
ttamttam has joined #ocaml
pimmhogeling has quit [Ping timeout: 245 seconds]
avsm2 has joined #ocaml
avsm1 has quit [Ping timeout: 264 seconds]
ikaros has joined #ocaml
ikaros has quit [Client Quit]
avsm2 has quit [Quit: Leaving.]
ikaros has joined #ocaml
itewsh has joined #ocaml
npouillard has quit [Ping timeout: 256 seconds]
npouillard has joined #ocaml
Associat0r has joined #ocaml
_zack has joined #ocaml
sepp2k has joined #ocaml
pimmhogeling has joined #ocaml
pimmhogeling has quit [Ping timeout: 245 seconds]
albacker has joined #ocaml
avsm has joined #ocaml
Yoric has joined #ocaml
boscop has joined #ocaml
avsm has quit [Ping timeout: 264 seconds]
<mrvn>
What does the command line look like when you compile?
pimmhogeling has joined #ocaml
avsm has joined #ocaml
ikaros has quit [Quit: Leave the magic to Houdini]
tmaedaZ has quit [Ping timeout: 264 seconds]
<flux>
echo open Batteries let _ = List.enum > foo.ml; ocamlfind ocamlopt -linkpkg -o foo -package batteries foo.ml
peper has quit [Ping timeout: 265 seconds]
_Jedai_ has quit [Quit: KVIrc Insomnia 4.0.0, revision: , sources date: 20090520, built on: 2009/06/08 19:18:46 UTC http://www.kvirc.net/]
maskd has joined #ocaml
pimmhogeling has quit [Ping timeout: 265 seconds]
pimmhogeling has joined #ocaml
tmaedaZ has joined #ocaml
avsm has quit [Quit: Leaving.]
Drk-Sd has joined #ocaml
matthieu has quit [Remote host closed the connection]
_andre has joined #ocaml
itewsh has quit [Quit: There are only 10 kinds of people: those who understand binary and those who don't]
<mrvn>
Could be made even simpler by defining a SLink and Dlink type but that would cost 2 values per object.
<mrvn>
tripling the cost for a single linked list and doubling for double linked list.
mutewit has joined #ocaml
<thelema>
mrvn: that's an amusing implementation, and definitely falls afoul of the dllist patent. :)
seafood has quit [Quit: seafood]
Gooffy has joined #ocaml
<mrvn>
Which isn't valid in sane countries anyway.
kaustuv has joined #ocaml
_zack has quit [Quit: Leaving.]
_unK has quit [Remote host closed the connection]
_unK has joined #ocaml
Jedai has joined #ocaml
jimmyb2187 has left #ocaml []
jimmyb2187 has joined #ocaml
noj has joined #ocaml
pimmhogeling has quit [Ping timeout: 245 seconds]
tmaedaZ is now known as tmaeda
Submarine has joined #ocaml
mutewit_ has joined #ocaml
mutewit_ has quit [Client Quit]
joewilliams_away is now known as joewilliams
<mrvn>
type 'a t = 'a data stripe
<mrvn>
type 'a lru_iterator = 'a t Iterator.Double.iterator
<mrvn>
ocamlc -i gives me: type 'a lru_iterator = 'a t Iterator.Double.iterator
<mrvn>
Why doesn't it use that type in later functions?
<mrvn>
I hate having to annotate or write mli files just to get the aliased types into a module signature.
pimmhogeling has joined #ocaml
<thelema>
flux: aha, it's because you're not using -thread - compiling without thread only provides Batteries_uni
sepp2k has quit [Read error: Connection reset by peer]
<flux>
thelema, oh, I should use Batteries_uni instead then?
<thelema>
yes
<thelema>
unless you're using threads.
<thelema>
(or don't mind the threads system being compiled in)
<mrvn>
Can't you automate that in the META file?
<thelema>
mrvn: no, we can't. We'd need two batteries.cmi files
<thelema>
and we can only have one.
<thelema>
the old solution was to have two different packages, but we're avoiding thta.
<mrvn>
How does the stdlib do it then?
<thelema>
mrvn: there's no module Stdlib
<thelema>
you just access each stdlib module directly.
<thelema>
just like flux was saying - the BatFoo modules are available under threads or non-threads
<mrvn>
-rw-r--r-- 1 root root 4.0K Feb 7 22:23 /usr/lib/ocaml/threads/threadUnix.cmi
<mrvn>
-rw-r--r-- 1 root root 21K Feb 7 22:23 /usr/lib/ocaml/unix.cmi
<thelema>
the compiler takes care of this as a special case.
<thelema>
there's one stdlib for non-threads and another for threads
<mrvn>
There is also:
<mrvn>
archive(byte) = "unix.cma"
<mrvn>
archive(byte,mt_vm) = "vmthreads/unix.cma"
<thelema>
there's hopefully no problem with batUnix
<thelema>
but there's only one unix.cmi
<thelema>
there's only one interface.
<thelema>
I guess we could stub out the threads modules in the Batteries_uni module...
<mrvn>
Two intrfaces for unix.
<thelema>
only one interface - unix.cmi
<mrvn>
What if you have /usr/lib/ocaml/threads/threadBatteries.cmi?
<thelema>
there's no vmthreads/unix.cmi
<mrvn>
true. native and vmthreads have one interface
<thelema>
thus stubbing in batteries
<thelema>
and apprently threadUnix is deprecated.
<mrvn>
Ahh, threads/threadUnix is actually the ThreadUnix module. right.
<mrvn>
So let me rephrase: What if you have /usr/lib/ocaml/threads/Batteries.cmi?
<thelema>
I don't know. I expect it won't get used, as only /usr/lib/ocaml is loaded into -I
<thelema>
I guess it might be possible to add more -I into the archive(mt)
<thelema>
I have no idea how, though.
pimmhogeling has quit [Ping timeout: 265 seconds]
<mrvn>
The -thread option must add /usr/lib/ocaml/threads or it wouldn't find the thread modules.
<thelema>
no, the thread modules are inside the .cma file
<thelema>
hmm, maybe not... I see .cmi files in ocaml/vmthreads
<mrvn>
thelema: which is threads/threads.cma
<thelema>
ah, it uses sub-packages
<thelema>
which we can do in batteries... nice
<mrvn>
Glad my clueless poking around helps. :)
<mrvn>
directory = "^"
<mrvn>
What does that do in META?
krankkatze has quit [Remote host closed the connection]
<thelema>
that's a good question. I don't know.
<thelema>
directory = "+vmthreads"
<thelema>
this makes sense.
<mrvn>
Could ^ mean the default libdir?
<mrvn>
Or maybe no dir?
<thelema>
I think it means up one directory
<thelema>
it's not documented, but that's what'd be needed, as the META.threads is in the METAS subdir
<mrvn>
I think I will try to use the same trick for my int31 module.
<mrvn>
actualy archive(byte) and archive(native) is enough for that. forget it.
krankkatze has joined #ocaml
<thelema>
yes, it usually is
<mrvn>
But I will keep it in mind for when I write a thread save hashtbl, tree or set.
sepp2k has joined #ocaml
<thelema>
it's only needed if you have different interfaces for the two.
<thelema>
maybe we should just provide one interface and two implementations...
CcSsNET has quit [Ping timeout: 265 seconds]
<mrvn>
Wouldn't I need the same error checking?
<mrvn>
and 'requires = "thread"'?
Gooffy has quit [Quit: Leaving.]
<mrvn>
thelema: The two implementations would need to be in different subdirs too
krankkatze has quit [Read error: Connection reset by peer]
krankkatze has joined #ocaml
<mrvn>
Hmm. another little problem. I have an 'a container storing Node.t. The container has val apply : 'a container -> ('a -> 'b) -> 'b. Now I want to add phantom types to have read/write nodes and read/write containers.
<mrvn>
[`Const] 'a container doesn't work.
<Alpounet>
shouldn't it be 'a [`Const] container ?
<mrvn>
'a [`Const | `Read | `Write ] container. yes. And val apply_const : 'a [`Const] container -> (???? -> 'b) -> 'b?
<mrvn>
How do Iget the 'a const too?
<Alpounet>
why would you need it to have 'a const too ?
<mrvn>
I guess I need to define a Node.t [`Const] type.
<Alpounet>
the actual values, stored in the container, must be tagged `Const, but not necessarily the function's input
<Alpounet>
should it ?
<mrvn>
Because the function must be one allowed on [`Const] Node.t
<Alpounet>
not sure you really need it
ttamttam has quit [Quit: Leaving.]
<mrvn>
I do.
<Alpounet>
then doesn't 'a [`Const] work ?
mutewit_ has joined #ocaml
<mrvn>
Say you have an (x : int ref [`Const] container) and someone calls apply_const incr x
mutewit_ has quit [Client Quit]
<mrvn>
Alpounet: Must be 'a [`Const]. That just isn't how phantom types usualy are placed.
<mrvn>
I can define read/write types but I can't get them to work like phantom types. print should work for both P.read and P.write
joewilliams_away is now known as joewilliams
mutewit_ has joined #ocaml
mutewit_ has left #ocaml []
<Alpounet>
what about having a `R tag and a `RW one, with "const" functions being of type 'a [`R], and others being [`R | `W]
<Alpounet>
'a [`R | `W] I meant
<mrvn>
# module type M = sig type t val foo : t [`R] -> unit end;;
<mrvn>
Syntax error: 'end' expected, the highlighted 'sig' might be unmatched
<mrvn>
How?
* Alpounet
firing up a toplevel
<mrvn>
I need a type 'a t and the [] takes the place of 'a
<mrvn>
But type t 'a isn't allowed.
<Alpounet>
what about [`R of 'a | `W of 'a] ?
<Alpounet>
and [`R of 'a] for read-only functions
<mrvn>
That wouldn't be a phantom then and the apply function would have to unwrap the constructor.
<Alpounet>
hmm
<Alpounet>
maybe you should try the caml mailing list for that one
<mrvn>
But maybe ('a, 'b) container with 'b being the phantom
<Alpounet>
yeah nice workaround
<Alpounet>
but ask on caml@, in case there's a nicer solution
travisbrady has quit [Quit: travisbrady]
ccasin has joined #ocaml
jao has quit [Ping timeout: 245 seconds]
<albacker>
is there any xml parsing library for ocaml with good documentation that you guys would like to share with me?
Yoric has quit [Quit: Yoric]
_zack has joined #ocaml
bmp has joined #ocaml
munga has quit [Quit: Ex-Chat]
peper has joined #ocaml
<mrvn>
Alpounet: Any idea how to declare type (('a, 'b), 'c) t?
<thelema>
mrvn: can't do - type paremeters are flat.
<thelema>
*parameters
Alpounet has quit [Ping timeout: 252 seconds]
<bmp>
When I attempt to run OCaml Batteries Included with the provided .ocamlinit, I get back: "Error: Unbound value Batteries_help.init".
<bmp>
I see batteries_help.mli and batteries_help.cmo in ocaml's site-lib, though; am I doing something wrong?
<thelema>
possibly. edit the provided .ocamlinit and change Sys.interactive := false to := true
<thelema>
this will show some messages that are hidden.
<thelema>
if you don't get a line saying that batteries_help.cmo is loaded, that would explain the problem.
<thelema>
The other thing to check is your version of findlib
<bmp>
I don't see anything obvious; in fact, right before it errors out, it even says "/opt/local/lib/ocaml/site-lib/batteries/batteries_help.cmo: loaded"
<bmp>
findlib is 1.2.5, which was listed as a version that should work.
<thelema>
yes, that's the newest, and what I'm using...
<thelema>
what ocaml version?
<bmp>
3.11.2
<bmp>
Built from source on Snow Leopard, in case that sets off warning bells.
<bmp>
I'm also not wedded to using Batteries; just trying OCaml for the first time in a few years, and the library looked very useful.
<thelema>
I'm doing my best to make it that way.
<thelema>
what version of batteries?
travisbrady has joined #ocaml
<bmp>
The tarball of 1.0.1 available on gforge.
<thelema>
1.1.0 is out - could you try that?
<bmp>
Sure; that just errored out with a totally different problem. :) Give me a moment to rebuild.
<thelema>
ah, lots of bugs to fix.
<thelema>
including how the batteries homepage says nothing about 1.1.0
demitar has quit [Quit: ChatSpace]
brooksbp has joined #ocaml
<bmp>
Okay, so the error with 1.1.0 on my system is "Reference to undefined global `BatIO'
<thelema>
in compiling?
<bmp>
No, on running; "omake test" passed. Although in this case, it's complaining it can't find batteries.cma, and I agree it's not there.
<bmp>
So omake install may not be doing something right.
<thelema>
possibly, although batteries relies on ocamlfind pretty completely for installation
<bmp>
I see batteries_uni.cma and pa_strings.cma in the batteries folder in site-lib.
<bmp>
As far as .cmas.
brooksbp_ has quit [Ping timeout: 245 seconds]
<thelema>
but no batteries.cma?
<bmp>
batIO.{cmi,cmx,mli} are there.
<bmp>
Correct.
<thelema>
is there a batteries.cma in src/?
<bmp>
Hmm. No. So the build failed, I suppose?
avsm has quit [Quit: Leaving.]
<bmp>
Wait, sorry, I'm wrong.
<bmp>
Yes, it's there.
<bmp>
batteries.{cma,cmi,cmo.cmx,cmxa,ml,o} are all there.
<thelema>
what happens if you copy it with?
<thelema>
.cma, cmi, cmx, cmxa
pad has joined #ocaml
<thelema>
copy to site-lib/batteries
<bmp>
Then I go back to Error: Unbound value Battereis_help.init.
<bmp>
So that did help.
<thelema>
well, that's sorta progress.
<thelema>
hmm. In the toplevel, ignoring the error, do you have access to batteries functions?
<bmp>
I'm happy to give you more output/library versions/whatever; I'm not sure what's useful to you in debugging this.
<thelema>
tap
<thelema>
|>
<bmp>
No.
<bmp>
|> was the first I tried, actually, before I came in here.
<thelema>
err, after [open Batteries]?
<bmp>
Oh, good call.
<thelema>
yes, the startup script opens batteries after trying to initialize help
<thelema>
(you can read along what the rest of the startup script does by looking at battop.ml
<bmp>
Okay, yes, I do have access to batteries functions.
<thelema>
ok, it's just a problem with batteries_help.cmo... hmmm
<bmp>
Well, also, one of ocamlfind or omake is not copying batteries.* for some reason.
<thelema>
could you try removing #thread;; from your battop.ml and reinstalling?
<bmp>
I can paste the install output into a pastebin, if useful; those are simply not listed.
<bmp>
Sure, one sec.
<thelema>
omake is somehow not finding it - except it uses wildcards to include every .mli, cmi, cma and .a file
<bmp>
I built whatever the most recent version of OMake was at the site listed by the readme. I may have built it wrong.
<bmp>
The wildcards don't seem to include .cma, for what it's worth.
<bmp>
Commenting out #thread;; has no effect.
<bmp>
Same error finding Batteries_help.init.
<thelema>
well, the best I have is a workaround - comment out the batteries_help.init line and live without it.
<thelema>
I'll look into snow-leopard vs. findlib - that's where the problem has to be.
<bmp>
I used MacPorts to install findlib, so I'm just scanning the portfile to make sure it doesn't do anything weird, but I'm not seeing anything that looks even remotely dubious here.
<bmp>
The only thing it does to findlib is pass in -mandir, -bindir, and -sitelib pointing at /opt/local/foo.
<thelema>
that's innocuous
<thelema>
And the wierd part is that batteries_help is loaded....
<bmp>
There are no other errors, but just in case a load order is wrong or something else helpful.
<bmp>
I unfortunately have to get to the airport shortly, but at some point later tonight or tomorrow, I can just give you a login to this box.
<bmp>
Meanwhile, I can just disable batteries_help, as you suggested.
<bmp>
Other than printing out a battery logo, am I missing much?
<bmp>
I gotta scram, but I'll check the logs here. Thanks for your help.
bmp has quit [Quit: bmp]
Alpounet has joined #ocaml
<Alpounet>
mrvn, type ('a, 'b, 'c) foo = (('a, 'b), 'c) t ?
<Alpounet>
hmm
* Alpounet
is silly
<thelema>
bmp: topinit.ml requires batteries, initializes the help, prints a logo, opens batteries, installs some printers, and loads the camlp4 with batteries
<Alpounet>
mrvn: type ('a, 'b, 'c) t = ('a * 'b) * 'c list
<Alpounet>
well, t instead of list
<thelema>
bmp: thanks for the offer - if I don't get to anything from my digging, I may take you up on the offer of a terminal.
<mrvn>
Alpounet: * creates a tuple. So the value is boxed
<mrvn>
Alpounet: But the ('a * 'b) needs to be a real value. Phantom types have no values
<thelema>
('a,'b) isn't a type, so you can't use it in a parameter list
Submarine has joined #ocaml
<mrvn>
thelema: That is the problem
<Alpounet>
thelema, yeah yeah, I forgot that during a moment
<mrvn>
I need to thet the 'M.t' out of the C module in my paste.
<thelema>
mrvn: do you mean that t can take only a tuple type as the first parameter?
<mrvn>
thelema: no
<mrvn>
thelema: I mean that I can't nest phantom types
<thelema>
then what do you mean by (('a,'b),'c) t?
<thelema>
if you meant type t with 3 parameters, you know the right way to write it.
<mrvn>
thelema: I mean (('a, 'b) M.t, 'c) t without the dependency on M.t
<mrvn>
(('a, 'b) 't, 'c) t if you will
<thelema>
that's like having [int 'a] - you can't parameterize the base type, only its arguments
<mrvn>
thelema: bingo
<mrvn>
thelema: know any way around it?
<thelema>
type 'a container = L of 'a list | S of 'a Set.t | E of 'a Enum.t
<travisbrady>
does anyone know of a guide somewhere describing how to estimate memory size for ocaml types?
<thelema>
then you can have a ['a container]
<mrvn>
thelema: with compile time type check
<thelema>
that would require compile-time binding based on types
<thelema>
travisbrady: practical or theoretical?
<thelema>
mrvn: i.e. overloaded functions
<mrvn>
thelema: no, totaly wrong direction
<travisbrady>
thelema: practical if possible
<mrvn>
thelema: Look at my paste.
<mrvn>
thelema: The problem is that M must be declared after C so I can't use M.t in C
<mrvn>
or rather I would like to not have recursive modules there
<thelema>
travisbrady: to measure memory usage in a running program, or just know how much space a given type takes up?
<mrvn>
travisbrady: the interfacing with C describes the memory layout of types
<thelema>
mrvn: recursive types
<thelema>
mrvn: recursive moduler
<mrvn>
thelema: But it is only recursive because I can't polymorphise a type with phantom types.
<travisbrady>
thelema: the former, i'd like to know how much space total i'll need for an estimated workload and what kind of gc behavior i can expect if possible
<thelema>
travisbrady: there's some patches to ocaml that'll help with getting memory usage somehow. I've never used them
<mrvn>
travisbrady: Gc.stat
<mfp>
travisbrady: it's easy. string -> data + 1/2 words array -> (num elements + 1) words, unit, int, bool, char 1 word. Sum types: num of constructor args + 1 (+ size of args, proceed recursively) (particular case: lists -> 2 * num elements + 1 words)
albacker has quit [Quit: Leaving]
<flux>
thelema, an idea regarding batteries/batteries_uni-situation. couldn't the different .cmi-files be stuck into different directories?
<thelema>
flux: yes, I'm working on that now.
<thelema>
I was distracted by the snow leopard bugs
<mrvn>
flux: submodules like /usr/lib/ocaml/METAS/META.thread has
<flux>
:)
<thelema>
I have to abandon my simple plan of using [ocamlfind install] to handle everything
<mfp>
tuples, same as sum types; polymorphic variants: num constructor args + 2 words
<travisbrady>
ahh, ok. but loosely can I expect a type like "type blah = { a : int; b : int }" to be the size of two machine ints + some overhead? how much is that overhead?
<flux>
mrvn, well, the problem is that for some reason batteries has actual different interfaces for those two cases, while the thread system apparently has identical interfaces
<mrvn>
mfp: 2?
<flux>
(I think)
<thelema>
travisbrady: for records, 1 word
<mfp>
travisbrady: 3 machine ints
<mrvn>
flux: nope.
<flux>
I mean, if the interfaces are the same, wouldn't the same .cmi work?
ulfdoz has joined #ocaml
<mrvn>
flux: No, I mean thread has 2 cmi files too
<mfp>
travisbrady: the overhead is always at least 1 word for the header
<travisbrady>
thelema, mfp: thank you
<thelema>
travisbrady: good luck
Associat0r has quit [Read error: Connection reset by peer]
<flux>
mrvn, right, so it uses the directory-thingy for that?
<mfp>
mrvn: polymorphic variants are represented as a tuple w/ the hash of the constructor and the remaining args
<mrvn>
flux: The trick is that it adds different subdirs depending on the flags. You just put the files in those dirs.
<mrvn>
mfp: iand without args?
<mfp>
travisbrady: (the above might have been ambiguous) -> the overhead in the above record is 1 word, and a value like {a = 1; b = 0} will thus take 3 words
<mfp>
mrvn: 1 word IIRC (just the hash, as a 31/63 bit int)
<mrvn>
mfp: thought so
<travisbrady>
mfp: and is a simple record like that always 1 word of overhead?
<mrvn>
travisbrady: a record is a header + space for the fields. Same as tuple.
<mfp>
travisbrady: the overhead is always going to be 1 word for records
<thelema>
travisbrady: yes, records, tuples, arrays all have the same internal storage - 1 word tag + n-words of pointers or data
pad has quit [Remote host closed the connection]
bzzbzz has joined #ocaml
<thelema>
eww, this findlib hacking is turning out ugly
<travisbrady>
does anyone have a sense of how large the gap is between ocaml and c in terms of how memory efficient an equivalent-ish program can be? apologies for the somewhat vague question
<mrvn>
travisbrady: approaching 0
<travisbrady>
mrvn: ahh, excellent
<mrvn>
but you will always use more
<mrvn>
for anything interesting anyway
<mfp>
not necessarily
<thelema>
travisbrady: in C there's lots of packing tricks to get things to take less space. In ocaml, values always have one word of overhead.
<mrvn>
On the other hand nobody really packs things
drunK has joined #ocaml
<thelema>
true. there's a difference between uber-optimized C and sane c
<mrvn>
Unions use more space in C than ocaml. So you could use less memory in ocaml.
<travisbrady>
thelema: yeah, fortunately the program i need to improve upon doesn't do anything terribly fancy, though it is written in C
<thelema>
travisbrady: just use better data structures and algorithms in ocaml and get better results.
<mrvn>
type x = Foo of int | Bar of float | Baz of large_thing_t. union { int i; double d; large_thing_t large; }
<mfp>
travisbrady: if you're not using your own allocator, OCaml values can easily be less memory-hungry than C (1 word < typical malloc overhead, also no fragmentation thanks to compacting major GC). Also, sum types are related to C unions with 2 advantages: smaller + type-safe.
<travisbrady>
yeah, I'll get to use a few bits in batteries/stdlib that I think are probably better in a few ways than the hand-rolled C stuff i'm trying to replace
_unK has quit [Ping timeout: 258 seconds]
<mrvn>
mfp: one can allocate unions to fit in C though. It just gets messy.
<mfp>
but then you have the malloc overhead (usually 2 words)
<travisbrady>
mfp: ahh, awesome. very helpful, thank you.
<mrvn>
mfp: has Baz of large too.
<mfp>
1 word < 2 words :-)
<mfp>
uh
<mrvn>
mfp: 1 header for Baz and 1 header for large itself.
<mfp>
you wouldn't put it in a separate record
<mrvn>
mfp: ocaml does
<mfp>
if mem-efficiency is a must
<mfp>
I mean Baz of field1 * field2 directly
<mfp>
instead of type t = { field1 : foo; field2 : bar} type asdf = ... | Baz of t
<mrvn>
I think where ocaml saves the most memory is by sharing values between blocks.
<mrvn>
let large = ... in Array.make 1000000 (Baz large)
Narrenschiff has joined #ocaml
<mrvn>
They all use the same large
<mfp>
then there's also hash consing and stuff
<thelema>
yup, ocaml makes sharing easy.
joewilliams is now known as joewilliams_away
<mrvn>
In C you would usualy write large_thing_t array[1000000]
joewilliams_away is now known as joewilliams
* thelema
gives up on findlib magic
enthymene has joined #ocaml
slash_ has joined #ocaml
drunK is now known as _unK
ttamttam has quit [Quit: Leaving.]
albacker has joined #ocaml
matthieu has joined #ocaml
Yoric has joined #ocaml
Narrenschiff has quit [Quit: Narrenschiff]
Yoric has quit [Quit: Yoric]
dark has joined #ocaml
smimou has quit [Ping timeout: 265 seconds]
Yoric has joined #ocaml
enthymene has quit [Quit: rcirc on GNU Emacs 23.1.1]
<flux>
man, the nonrecursive type limitation is sometimes annoying
Submarine has quit [Ping timeout: 245 seconds]
<flux>
I've been just wondering a piece of code why it doesn't compile, but finally figured out that it does indeed do type recursion (cps-style loop), so I added `V and it compiles
Yoric has quit [Client Quit]
<thelema>
let enum_ranges_f x = enum_ranges_f x |> tap (Enum.clone |- Enum.print (Pair.print Int.print Int.print) stdout)
* thelema
is having fun with closures
<thelema>
and partial evaluation
Modius has quit [Ping timeout: 246 seconds]
Yoric has joined #ocaml
mutew has joined #ocaml
* thelema
is doing aspect oriented programming:
<thelema>
let enum_ranges_f =
<thelema>
tap (field_to_string |- print_string)
<thelema>
|- enum_ranges_f
<thelema>
|- tap (Enum.clone |- Enum.print (Pair.print Int.print Int.print) stdout)
pad has joined #ocaml
seanmcl has joined #ocaml
_andre has quit [Quit: *puff*]
enthymene has joined #ocaml
<mrvn>
type x = { x : int; } type y = { x : int; y : int } let y = { x = 1; y = 2; } (y :> x);;
<mrvn>
Error: Type y is not a subtype of x
<mrvn>
I so wish that would work without Obj.magic.
Yoric has quit [Quit: Yoric]
mutew has quit [Quit: leaving]
smimou has joined #ocaml
astronut has joined #ocaml
<astronut>
what's the appropriate way to access a type from a module signature? this fails: module type FOO = sig type bar end;; module type BAZ = sig val foobar: int->FOO.bar end;;
<astronut>
never mind
astronut has left #ocaml []
joewilliams is now known as joewilliams_away
sepp2k1 has joined #ocaml
Alpounet has quit [Ping timeout: 265 seconds]
sepp2k has quit [Ping timeout: 265 seconds]
ccasin has quit [Quit: Leaving]
Alpounet has joined #ocaml
seafood has joined #ocaml
joewilliams_away is now known as joewilliams
ygrek has quit [Ping timeout: 245 seconds]
seafood has quit [Quit: seafood]
enthymene has quit [Quit: rcirc on GNU Emacs 23.1.1]
gkelly has left #ocaml []
Yoric has joined #ocaml
_zack has quit [Quit: Leaving.]
valross has joined #ocaml
Yoric has quit [Ping timeout: 248 seconds]
Yoric has joined #ocaml
enthymene has joined #ocaml
<brooksbp>
hello
<brooksbp>
say I have a function that takes 2 arguments and returns a set... how do I then call that function again on the set that it previously returned?
<thelema>
let f a b = Set.singleton (a*b)
<thelema>
??
<thelema>
brooksbp: you want to do recursion?
<thelema>
or you want to just call a function more than once?
<brooksbp>
Something like: let s' = myfun a1 s .... now, I want to compute (myfun a1 s'1) u (myfun a1 s'2) u .... (myfun a1 s'n)
<brooksbp>
where s' = s'1, s'2, ... s'n
<thelema>
u = Set.union?
<brooksbp>
yes, union
<brooksbp>
I thought about using something like map, but I can't union the return values from map. I was hinted to use fold?
<thelema>
s'n = myfun a1 s'(n-1)?
<thelema>
I assume this is some sort of school assignment?
<brooksbp>
no, s'n is just the last element in the set that got returned by the first call to myfun (inside the let)
<thelema>
but a is a set, and s'n isn't a set
<thelema>
how can you call myfun both ways?
<thelema>
err, s is a set
<thelema>
but assuming two different [myfun], you do need a fold - look at Set.S.fold
<brooksbp>
Hmm let me rephrase... let s = myfun a1 a2.... now how do I union all the results from calling (myfun a1 x) where x is an element of s.
<thelema>
This may not be the answer you want, but [myfun a1 a2 ... |> Set.map (myfun a1) |> Set.fold (fun acc x -> Set.union x acc) Set.empty
<thelema>
]
<thelema>
|> is defined: [let (|>) x f = f x]
<thelema>
You can with little work simplify the map and fold into a single fold, but I'm apparently lazy.
<thelema>
and I realize now that I didn't need to invert the order of arguments on Set.union, although as presented, it's more helpful for inlining the map
<brooksbp>
oh man I do not understand that at all
<thelema>
ok, I'll use more lets
<thelema>
let set = myfun a1 a2 ... in
<thelema>
let mapped = Set.map (myfun a1) set in
<thelema>
let answer = Set.fold (fun acc x -> Set.union acc x) Set.empty mapped
<brooksbp>
wont mapped = nil... because you can't get the return values from Set.map for each myfun call when you map?
<thelema>
Well, you have to be using polymorphic sets to do Set.map and have the result be a valid set of sets...
<thelema>
let's do this a different way:
<thelema>
let elements = Set.to_list set in
<thelema>
let mapped = List.map (myfun a1) elements in
<thelema>
let answer = List.fold_left (fun x acc -> Set.union x acc) mapped Set.empty
ulfdoz has quit [Ping timeout: 245 seconds]
mutewit has quit [Read error: Connection reset by peer]
mutewit has joined #ocaml
Yoric has quit [Quit: Yoric]
boscop_ has quit [Read error: Connection reset by peer]
synod has quit [Quit: Page closed]
<albacker>
Hello, anyone has add experience with pxp (xml parser)?
Amorphous has quit [Ping timeout: 264 seconds]
brooksbp has quit [Quit: Leaving...]
albacker has quit [Ping timeout: 258 seconds]
enthymene has quit [Quit: brb]
valross has quit [Remote host closed the connection]