<hcarty>
companion_cube: set/modify introduces some trouble with map
<hcarty>
zorun: I think so
<zorun>
hcarty: oh, right
<hcarty>
zorun: IIRC there have been some changes to ocamlbuild's handling of ocamldoc over the last few months.
<hcarty>
zorun: It may need some myocamlbuild.ml customization, or the trunk version of OCaml
<hcarty>
companion_cube: Seamless switching between arrays and mmap'd bigarrays
<hcarty>
companion_cube: That's the original reason I put this together
<hcarty>
Files! Right, that was the other extra resource I was thinking of
<hcarty>
companion_cube: Yep
<hcarty>
('index, 'element, [`mutable | `immutable]) t or something like that
<companion_cube>
hcarty: indeed
<hcarty>
companion_cube: And an extra type parameter could be used to track mutability of the underlying structure.
<hcarty>
companion_cube: I may be convinced of the utility of modify. If you wrap a database handle, for example, it could be useful to read from and write to the same index.
<hcarty>
kaustuv: I imagine that's true for even more cases if you're wrapping an extra function call around everything
<hcarty>
companion_cube: My original response to your mem request was to say, "return an 'element option from your get function and you won't need it" :-)
<hcarty>
I'd rather avoid pushing off errors to exceptions at runtime
<hcarty>
I'm already a little concerned about mem :-)
<companion_cube>
hcarty: I think it should be an optional function
<hcarty>
companion_cube: Or feasible to implement cleanly
<hcarty>
companion_cube: I've thought about modify but I'm not sure it's a good idea
<companion_cube>
hcarty: I think the abstraction is still very interesting
<hcarty>
companion_cube: I'm planning to bring up IndexMap on batteries-devel once I've done a bit more testing to heck for glaring errors.
<companion_cube>
hcarty: would you talk about your idea of 'a Index.t on batteries-devel?
<companion_cube>
hcarty: yes, I've been thinking about that too
<hcarty>
companion_cube: I don't remember the details of the discussion, but from what I remember it came down to it being too easy to make mistakes and too hard to keep track of assumptions about which comparison function is being used.
2013-03-01
<companion_cube>
hcarty: looks very nice
<wmeyer>
hcarty: actually Iarray was a bit of joke - I made a library called Ilist but feel free to use. (which has completely different purpose than your IArray!)
<hcarty>
Thanks for the suggestions
<hcarty>
IndexMap for now. Iarray or Garray may win out later.
<hcarty>
It's sort of a map but not in the stdlib/Batteries/Core sense of ordered keys.
<hcarty>
I'm trying to put some basic ocamldoc comments in place and the naming is making it difficult.
<hcarty>
Well, the 'basic' operations are the first four functions listed in the S signature. The rest are based on those four.
<hcarty>
companion_cube: I'm not sure, but if the basics work that I'd propose it as an incubator module in Batteries.
<companion_cube>
hcarty: do you think there are other kinds of such useful abstractions
<hcarty>
I'd definitely like to have functions as the element providers.
<hcarty>
I haven't experimented enough to know if it's possible in OCaml without functors or classes/objects.
<companion_cube>
hcarty: I think it's more clean to have both
<hcarty>
companion_cube: Or 'e would be ('a Sequence.t) in that case
<hcarty>
companion_cube: Indeed!
<hcarty>
Along the lines of: type ('index_type, 'element_type) index ... val get : ('i, 'e) index -> 'i -> 'e
<hcarty>
Enum, Seq, Sequence provide generic collections/enumerations of elements. Is there something similar for indexed collections of elements?
<hcarty>
vivanov: Some experimentation is usually required to find the 'best' approach, for better or worse.
<hcarty>
vivanov: Could be the implementation. You could read all of the text at once then convert it. Again, the best approach will depend on your specific environment.
<vivanov>
hcarty: im doing it now
<hcarty>
vivanov: Or you could convert the data before bringing it into OCaml. Which is best would depend on how you are using the data.
<hcarty>
vivanov: Read each line, parsing each one to get a float array
<vivanov>
hcarty: so whats the best way to convert 1.5m x 20 float number file to array of arrays in ocaml ?
<hcarty>
vivanov: Unless you are mapping a Bigarray with character elements
<hcarty>
vivanov: Bigarray.*.map_file expects a native-binary representation, not text
2013-02-28
<thelema>
which I've already done, in a way. hcarty was just responding to my post
<hcarty>
thelema: Yes
<thelema>
hcarty: they would stick around, and be implemented on top of this infrastructure
<thelema>
hcarty: I have to give credit to Yaron; it was his idea, which I (at the time) immediately rejected as impossible, but have since realized that stripping away length and clone make it simple and elegant
<hcarty>
thelema: What would this mean for the default/pervasive Enum functions and operators? Would then stick around or be replaced by something else?
<hcarty>
thelema: It may enrage gasche to discuss this here before moving to the mailing list, but for what it's worth I like your proposal. It is simple and should cover basic functionality.
<hcarty>
tautologico: Sadly no. If you are using an opam-managed compiler then it can do that.
<tautologico>
hcarty: yeah, it's probably that, I think I know how to solve it… any way to recompile via ocamlbrew or do I have to install everything again?
<pygmalion>
hcarty: At least it's good to know that it *should* work.
<pygmalion>
hcarty: Fair enough, thanks.
<hcarty>
s/the a/the/
<hcarty>
pygmalion: I'm not sure what the a minimal set would be
<hcarty>
pygmalion: I don't remember which packages were installed. This install is shared by several people and has a lot of development RPMs installed.
<pygmalion>
hcarty: by every time I mean with various different patched versions
<pygmalion>
hcarty: What prereqs did you install? I'm starting from a fresh CentOS 6 (64 bit), doing "yum install make gcc" and then using the opam bootstrapping installer (http://opam.ocamlpro.com/doc/Quick_Install.html) and failing with those errors every time.
<hcarty>
def-lkb: Updated master via :BundleInstall!, same result under 7.2 and 7.3
<hcarty>
tautologico: The OCaml configuration script was probably unable to find the relevant X headers. I don't remember which headers it needs, but I've had trouble with that before.
<hcarty>
opam
<hcarty>
pygmalion: I was able to build OCaml 4.00.1 and a few the patched versions of 4.00.1 on CentOS 6 (64bit) through oapam
<hcarty>
def-lkb: I've tried with vim 7.2 and 7.3
<def-lkb>
hcarty: btw, update master, I fixed a synchronization bug introduced by removing use of py2.7 Counter class
<def-lkb>
hcarty: which version of vim are you using ?
<hcarty>
def-lkb: The problem seems (?) to be in the handoff between vim_complete_cursor and merlin#Complete
<def-lkb>
hcarty: some cases don't work anymore… anyway, it's a work around ugly vim design…
<def-lkb>
hcarty: the current fix is buggy
<rks_>
hcarty: seeing the log, the send_command seems to be working
<hcarty>
"it" being print statements from python. Not merlin yet, sadly.
<hcarty>
rks_: Never mind, it does seem to be working. But something isn't working with omnicomplete because the send_command function isn't being called, or isn't producing the same print output as it does when performing type lookups
<hcarty>
rks_: I'm trying to dump data and track where things are being lost but not having much luck.
<hcarty>
rks_: Do you know how to get some sort of text message from a vim python plugin to the terminal/vim?
<hcarty>
That gives me a starting point if I want to dig into this further.
<hcarty>
rks_: It's ok, thanks for the MERLIN_LOG tip!
<hcarty>
rks_: To my untrained eye that looks like a reasonable final "return" value
<hcarty>
rks_: The same configuration works fully on a different Ubuntu 12.04 system. Both are using OCaml 4.00.1 and merlin from opam.
<hcarty>
rks_: But, for example, if I type List.<c-x><c-o> I get an error/message saying that there aren't any matches.
<hcarty>
rks_: Sure. If I open an OCaml source file in vim, I can type "\t" to see the type of the expression under the cursor in normal or visual mode.
<rks_>
ok so hcarty, can you describe a bit more your problem?
<hcarty>
def-lkb: Thank you for the older python compatibility none the less
<hcarty>
rks_: Doesn't look like it. I still get the same result (types report, no omnicomplete).
<hcarty>
def-lkb: Thanks for working on a fix
<hcarty>
rks_: Excellent, thanks! I'll update my local copy and see how it goes.
<hcarty>
rks_: I built (using pythonbrew) Python 2.7.3 and vim 7.3 against the updated Python.
<hcarty>
rks_: I am trying to use merlin on a CentOS 6 system. The system Python is 2.6 so it doesn't work with merlin's vim plugin.
<rks_>
hcarty: what do you mean?
<hcarty>
def-lkb: Any ideas on why querying expression types works but omnicomplete doesn't? I'm happy to put effort into diagnosing the issue but I'm not very familiar with vim + python + ocamlmerlin hacking.
2013-02-27
<def-lkb>
hcarty: Sorry I wasn't there
<thelema>
hcarty: I'm putting up with elisp for the same goal, so I guess it's all good
<hcarty>
s/will/willing/
<hcarty>
thelema: The python code is for the vim <-> OCaml interactions as companion_cube guessed. I'm will to put up with a bit of python for a better OCaml world :-)
<hcarty>
def-lkb: Finally finally - thanks for merlin! On my Ubuntu box where it works, it's amazing.
<hcarty>
def-lkb: Finally, this same vim configuration works on an Ubuntu 12.04 machine with (native) vim 7.3 and Python 2.7. Any suggestions for where to start troubleshooting?
<hcarty>
def-lkb: But omnicomplete always says 'Pattern not found'
<hcarty>
def-lkb: merlin now half-works. I can see types (\t, \n, \p), :Use packages and .merlin project files.
<hcarty>
companion_cube: Indeed :-)
<hcarty>
def-lkb: To work around this I tried to build a new Python version (using pythonbrew) and a new vim binary pointing to the updated Python.
<hcarty>
thelema: Yes
<hcarty>
thelema: Nope! :-) Well, maybe. But this is for the merlin vim/emacs helper.
<thelema>
hcarty: wrong channel, I think
<hcarty>
def-lkb: I'm having an odd issue with merlin on a CentOS 6 installation. The system Python version is 2.6 which doesn't include one of the classes used by merlin.py.
2013-01-09
<thelema>
hcarty: thanks. It's *way* overdue, but thanks to cedric taking the time to fix up modules, it actually happenned.
<hcarty>
thelema: Congratulations on getting 2.0 out - it's a nicely cleaned up version of Batteries.
<hcarty>
thelema: Never mind - it's a known and fixed bug post-4.00.1
<hcarty>
thelema: It works fine in actual use from what I can see.
<hcarty>
thelema: A little bit weird - I tried ( |> ) in the toplevel to see what would come back (OCaml 4.00.1). Error: The external function `%revapply' is not available
<hcarty>
thelema: Cool, thanks
<thelema>
hcarty: yes, one of the closed issues in batteries, IIRC
<hcarty>
discussion ON replacing...
<hcarty>
thelema: I think there was a discussion replacing ( |- ) with ( %> ) - Do you know where that took place?
2013-01-04
<flixr>
hcarty, thanks for the tip
<hcarty>
flixr: Debian may be applying patches to the xml-light package
2012-12-30
<wmeyer>
hi hcarty
2012-12-28
<testcocoon>
hcarty: OK, it seams that I can read the variable %{$NAME:$VAR}%, but how can I set it?
<hcarty>
testcocoon: Section 4 in that document makes it look like you can set per-package variables at the opam level. I'm not sure how to use the values, but the information you need may be there.
<hcarty>
Even slower than using functors from what I recall.
<hcarty>
I'm not sure if I can sanely merge the two modules, but I'd really like to if possible.
<hcarty>
thelema: My current implementation uses two modules with very similar code supporting slightly different record types
<hcarty>
thelema: I think so. I'm just playing around with the object/class system a bit to see if it makes solving a problem easier.
<thelema>
hcarty: ocaml has multiple inheritance, but since classes are structurally typed, I'm not sure what you want.
<hcarty>
Is there an equivalent to this polymorphic variant syntax with object or class types? type ta = [ `a ] type tb = [ `b ] type tab = [ a | b ]
2012-12-18
<thomasga>
hcarty: it works now :-)
<hcarty>
thomasga: Cool, thanks. I got a request to add a flag to ocamlbrew to build OCaml + opam, but if opam will be able to do that on its own then that's wonderful.
<hcarty>
thomasga: Do you expect 0.9.0 to work without an existing OCaml installation?
<hcarty>
Foo.print and Foo.pp (or IO.Foo.(print, pp)) are likely plenty. Syntax extensions can build on those if it's helpful.
<thelema>
hcarty: agreed
<hcarty>
It doesn't serve much purpose without the syntax extension.
<hcarty>
thelema: If you remove pa_estring then it's probably worth removing BatPrint too.
<hcarty>
thelema: I don't think either of those rely on anything in Batteries that they couldn't access as outside modules.
<hcarty>
thelema: :-)
<hcarty>
adrien: Some compile-time conversion could be done - not sure if it is. It also avoids polluting the namespace with single letter values.
<flux>
hcarty, I wonder if something like the haskell Lenses library for ocaml would be suitable for the same use as well
<hcarty>
flux: The biggest benefit in my experience is getting nicely formatted nested structures. I usually write a short pp_foo function to wrap any optional/output pieces.
<hcarty>
flux: All of the labeled arguments are optional
<flux>
hcarty, can you give an oneliner example?-)
<hcarty>
flux: It's handy!
<invariant>
hcarty, perhaps I would even go so far to declare OCaml as dominating over shell code for such tasks.
<flux>
hcarty, hmm, sounds interesting
<hcarty>
flux: BatIO.Enum.pp = Format-based printer for Enums (and lists and arrays...)
<invariant>
hcarty, shell code is over 1.3 seconds
<invariant>
hcarty, 160000 files in 0.120 seconds of real time.
<thelema>
hcarty: ok, I'll pull your changes
<hcarty>
invariant: Sys.readdir was fast enough? That's good.
<hcarty>
thelema: If I get time to do so I'll work on a pull request for that and maybe some implementations for other modules.
<hcarty>
thelema: Given that the code is in the repository history now, it's probably worth basing everything on Enum.pp. I would hope that a minor speed decrease in a collection pretty-printer wouldn't cause trouble.
<invariant>
hcarty, it's about 10 times faster than obvious shell code.
<invariant>
hcarty, it's plenty fast for my purposes, but a shell command was too slow.
<thelema>
hcarty: minor efficiency reasons, but that's all I can think of.
<pippijn>
hcarty: I don't use enum at all
<hcarty>
let ( |- ) f g x = g (f x)
<hcarty>
invariant: Batteries - that snippet is equivalent to (fun x -> Array.length (Sys.readdir x))
<hcarty>
invariant: One of those may have something.
<hcarty>
invariant: Aside from (Sys.readdir |- Array.length), you could look at the extunix library and/or fileutils.
<hcarty>
thelema: Looking back at the BatIO.Foo.pp functions, is there a reason to have a concrete implementation aside from BatIO.Enum.pp? Everything else, or almost everything else, could be implemented as something close to (Foo.enum |- Enum.pp ~first ~last ~sep ...)
2012-11-08
<hcarty>
gustav__: List.iter
<hcarty>
OCaml expects an expression that evaluates to unit on the left of ';'
<hcarty>
gustav__: You have a
<hcarty>
;
<hcarty>
s/returns a map/returns a list/
<hcarty>
gustav__: List.map returns a map. You probably want List.iter if you are looping through purely for output (side-effects).
<hcarty>
gustav__: Does a minimal example with Batteries work?
<hcarty>
gustav__: What does 'ocamlfind query batteries' say?
<hcarty>
gustav__: I'm guessing that the ',' on line 6 shouldn't be there
2012-11-06
<hcarty>
iZsh: That too
<Qrntz>
hcarty, didn't experience that — it looks very fit for recursive functions matching lists, for example
<hcarty>
Qrntz: It's not as obvious at a glance how many arguments the function takes
<hcarty>
Qrntz: That can make it harder to read the function though
<hcarty>
xavierm02: If you only want one then let (_, b, _) = tuple_with_three
<hcarty>
xavierm02: (2) You can pattern match - let (a, b, c) = tuple_with_three
<hcarty>
xavierm02: (1) fun is commonly used for anonymous functions
<hcarty>
xavierm02: (1) You never need function, but it can be useful
<hcarty>
xavierm02: It is not possible for tuples
2012-11-05
<hcarty>
thelema: Same trouble/result here
<thelema>
hcarty: I can't seem to make it type properly either... the type parameters seem to keep me from being able to nail down the types...
<hcarty>
I'm not sure how to get the function to type properly though.
<hcarty>
flux: Exactly! Calling the function probably requires more typing than doing the conversion manually... but that seems like a small price to pay.
<hcarty>
Gives a list, clearly.
<hcarty>
unenum (module BatList) some_enum
<hcarty>
flux: That will be the function using first class modules to do the same thing :-)
<hcarty>
wieczyk: To expand on _habnabit's answer a bit - many/most modules in Batteries have Foo.enum (convert to enum) and Foo.of_eunm (convert from enum) functions.
2012-11-04
<pippijn>
hcarty: I added a hack so that .nw files are also recognised
<hcarty>
pippijn: oasis is fairly stable for what it currently supports. Most new development would be to add features or fix bugs.
<adrien>
hcarty: I'm going to wonder if I'm the only one happy with the forge's VCS features
<hcarty>
adrien: In large part to encourage external contributions
<hcarty>
adrien: Yes, moved over under the 'ocaml' name along with oasis-db
<hcarty>
Don't know if that matters here, but I imagine it could.
<hcarty>
My LC_ALL is blank
<hcarty>
Same for all LC_* environment variables
<hcarty>
LANG=en_US.UTF-8 in the environment
<hcarty>
travisbrady: I have a working ocamlbrew install also under a 64bit Ubuntu VM. No issues with utop.
<hcarty>
It's a text encoding issue. I'm not sure what would trigger it though.
<hcarty>
It looks like this is an exception from Camomile. Maybe somehow due to encoding/locale settings.
<travisbrady>
hcarty: no, the physical install works perfectly so far.
<hcarty>
I don't know if that matters, but I guess it could affect something in Camomile or utop.
<hcarty>
Is the VM a 32 or 64 bit Ubuntu?
<hcarty>
Do you get the same error on your physical-machine install?
<hcarty>
travisbrady: That error may be coming from Camomile. I'm not sure what would cause it though.
<hcarty>
travisbrady: I'm not sure what would cause that issue. Do you have other OCaml installations in your path? Did you source ocamlbrew.bashrc?
<travisbrady>
hcarty: looked over the log and everything was clean
<hcarty>
travisbrady: I haven't. What steps did you take?
<hcarty>
pippijn: Can you convert the offending script to work with ocamlscript? That would give you a compiled, backtraceable result.
<hcarty>
pippijn: Not without a patch
<hcarty>
wieczyk: ocamlbrew it! opam it! GODI it! All the cool parties are happening in 4.00.1 land!
<Kakadu>
hcarty: We need a man who asks `WTF is ocamlbrowser?` :)
<hcarty>
I use it often, particularly with new libraries
<hcarty>
Kakadu: Me too!
2012-10-25
<pippijn>
hcarty: that requires dependent types
<pippijn>
hcarty: and I want the type to reflect that the returned variant is the requested one
<pippijn>
hcarty: I want to return one of them depending on which variant_kind is passed
<pippijn>
hcarty: I have a tuple of 3 variants
<hcarty>
pippijn: Wouldn't that still work?
<pippijn>
hcarty: add a .mli with val get : variant_kind -> 'semantic variants -> (variant_kind, 'semantic) variant
<hcarty>
pippijn: It works on 4.00.1 (where works = I can paste it into the toplevel without getting type errors)
<hcarty>
pippijn: What error do you get with your pastebin'd code?
2012-10-23
<hcarty>
thelema_: Same here. Looks like a bug.
<hcarty>
thelema_: But I don't know if it will work with any of the tarball releases
<hcarty>
thelema_: You could try applying the patch with ocamlbrew -p /path/to/patch ...
<hcarty>
That's most if not all of the reason I had the hackish three environment variables in place.
<hcarty>
It's something I wanted to have but never took the time to add. I'm glad you did.
<hcarty>
thelema_: The -v option is very convenient. Before you could do the same thing but had to know the Subversion structure a bit: ocamlbrew -s release/4.00.1
<hcarty>
thelema_: I won't argue
<thelema_>
hcarty: no problem. Now I can post something on the mailing list about how easy it is to install many versions of ocaml simultaneously
<hcarty>
thelema_: Thanks for the patch!
2012-10-22
<hcarty>
flux: Clearly this should be added to the code style guidelines!
<hcarty>
module FooBar = ...
<hcarty>
let foo_bar = "baz"
<hcarty>
ker2x: The most common format seems to be underscores for things starting with lowercase letters, camel-case elsewhere.
<hcarty>
ker2x: The tutorial material could use some help, but it's a nice playground and learning tool.
<hcarty>
ker2x: That's the goal! :-)
<hcarty>
ker2x: Yes
<hcarty>
ocamlbrew + odb (a package/library installer) is more light-weight/bare. GODI is heavier but has more robust dependency handling.
<hcarty>
ker2x: Or GODI
<hcarty>
ker2x: You can use ocamlbrew to compile a newer version
<hcarty>
You're welcome. You can also pattern match lazy values.
<hcarty>
let result = Lazy.force some_lazy_value in ...
<hcarty>
That expression wouldn't print anything until 'forced'
<hcarty>
ker2x: lazy (print_string "Hello")
<hcarty>
ker2x: No, not in the core language at least
<hcarty>
In the mean time, Core and Batteries do a nice job of filling in the gaps in the INRIA standard library
<hcarty>
ansx: I've opened lots of files >1G on a 32bit system using OCaml. I haven't worked on a 32bit system in a while, but I didn't have any trouble with it ~5-6 years ago.