<dyamon>
Hi everyone! OCaml noob here! In a project I have a module called `Buffer`, but since I'm using `base`, whenever I `open Base` at the top of a module, my own `Buffer` module gets shadowed by `Base.Buffer`. Is there a standard way of solving this?
pi3ce has joined #ocaml
<discocaml>
<_ggole> Use a different name, or bind `Buffer` to a different name above the `open Base` and then use that
<discocaml>
<_ggole> Or don't `open Base` and use everything qualified
<dyamon>
Ok so I take there is no way to `open Module except [list of modules]`
<discocaml>
<darrenldl> don't believe so
<discocaml>
<darrenldl> thought you might be able to access the regular stdlib buffer via `Stdlib.Buffer` even after `open Base`
<discocaml>
<darrenldl> though*
<discocaml>
<._null._> If it's their own Buffer, it won't be accessible under Stdlib.Buffer
micro has quit [Ping timeout: 245 seconds]
<dyamon>
Yeah it's my own module. I guess I'm attached to the name for no reason. I should just change it.
<dyamon>
On a side note, is adding `open Base` to your modules the right way to use the library?
<discocaml>
<._null._> If the module is defined in another file, you can also write `module Buffer = MyFile.Buffer` after `open Base`
<discocaml>
<darrenldl> Oh...sorry I failed to read the sentence properly
<dyamon>
So the thing is, it is a file module. I tried something similar before coming here, which was `module Buffer = LibName.Buffer` but the compiler returned a "This doesn't make sense to me" error.
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
waleee has joined #ocaml
a51 has joined #ocaml
bartholin has joined #ocaml
neiluj has quit [Quit: neiluj]
meator has joined #ocaml
<meator>
Hi. I don't have any experience with OCaml, but I'd like to package a program written in it. To do that, I need to know how do libraries in OCaml work.
<meator>
dune says that the library couldn't be found. How can I debug this problem? How does OCaml (or ocaml-findlib) look for libraries?
<meator>
Does opam distribute built things or does it just download source code and then build it?
<octachron>
opam is a source package manager
<octachron>
if a library cannot be found and has been installed by opam, one possible reason might be that there is two ocamlfind installations in scope (one managed by opam, and a system wide one)
<meator>
It hasn't been installed by opam. I am packaging the library manually.
<meator>
I could have missed something while packaging the library.
<meator>
I have experience with C, C++ and Python. Do I need to specify the library path (like -L in C)? Or could my library have some files missing which makes dune ignore it (kinda similar to __init__.py in Python)?
sleepydog has joined #ocaml
<meator>
https://termbin.com/hecl This is the library. I have noticed special files META and opam.
<discocaml>
<Ada> use opam to build it
<discocaml>
<Ada> the built executable won’t have any runtime dependencies on opam packages, but it’s like trying to build a rust package without cargo
jakzale has joined #ocaml
<meator>
When packaging things, it is discouraged to use other package managers. For example all Python dependencies are packaged manually and pip is never used.
<meator>
How is rust related to this?
<companion_cube>
i sure hope you use dune
<meator>
I am using dune.
<meator>
Or I am using a Makefile which is using dune.
whereiseveryone has joined #ocaml
arya_elfren has joined #ocaml
brettgilio has joined #ocaml
<companion_cube>
then I don't think you should worry about any C flags
<discocaml>
<Ada> if you want to use your distributions build system you should ask whoever maintains the ocaml packages for that distribution, they will know the ins and outs of how they handle build dependencies better than we will
migalmoreno has joined #ocaml
b0o has joined #ocaml
henrytill has joined #ocaml
richardhuxton has joined #ocaml
ggb has joined #ocaml
seeg has joined #ocaml
toastal has joined #ocaml
pluviaq has joined #ocaml
soni_ has joined #ocaml
ymherklotz has joined #ocaml
<discocaml>
<Ada> to be completely honest, i would not package for a language you are not familiar with
<meator>
The Void packages repository (which I'm working with) doesn't have much OCaml in it. I am unsure if I'll be able to find someone with experience.
<discocaml>
<Ada> if you are able to use a package manager at build time, use opam as a build dependency. otherwise, you're probably commiting yourself to maintaining too many packages and shell scripts for a single task in a language you arent using, but thats just my advice
<companion_cube>
I don't honestly remember where ocamlfind looks
<discocaml>
<Ada> `CAML_LD_LIBRARY_PATH`
<meator>
Is /usr/lib/extlib/ a reasonable location for the library? Or should it be somewhere else? To my knowledge other OCaml libraries are structured like that and they work. Can I invoke the library search mechanism manually somehow and observe its results to help me "debug" this?
<discocaml>
<Ada> i believe `/usr/lib/ocaml/` is the common default
<discocaml>
<Ada> at the least its where debian throws its stuff
Tuplanolla has joined #ocaml
rgrinberg has joined #ocaml
<meator>
I'm trying it right now.
<meator>
Packaging usually doesn't require deep knowledge of the language (but it certainly helps) if the build system is usable.
<meator>
I think it's working. Thanks Ada!
<discocaml>
<Ada> compare dune to cmake and dune looks incredible lol
average has joined #ocaml
<meator>
I've been lucky enough that the Void packages repo has "endpoints" for popular build systems like make, CMake, cargo etc. which handles everything (including more complicated things like cross compilation). I wouldn't want to touch CMake directly. Meson is the best!
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
<meator>
And just checking: Is it impossible to cross compile OCaml?
<discocaml>
<Ada> i think it’s possible
<discocaml>
<Ada> i’ve cross compiled from linux to windows before so i don’t see multi arch compilation being impossible
<discocaml>
<Ada> apparently it’s possible with nix, but that’s adding in a build time package manager and a huge container based one at that so
<meator>
I've read online that it's impossible except for some specific things like cross compilation to android, mac and windows. But I will look into it more.
<meator>
But it would require a build of OCaml compiler set up for cross compiling to the target architecture, no?
fweht has joined #ocaml
<discocaml>
<Ada> the windows cross compiler built for windows same architecture when i used it
<discocaml>
<Ada> don't know how the android ones work
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<meator>
I have chatted with people more knowledgeable than me and using opam should be OK.
<meator>
Thanks for your help! You have answered all of my questions. I am a stranger to these lands, but OCaml seems nice (at least it's build system).
<discocaml>
<Ada> the tooling is very nice
<discocaml>
<Ada> opam is a masterpiece
a51 has quit [Quit: WeeChat 4.1.2]
<adrien>
I shell scripted a task today and it was a bit too slow to be pleasant to use so I tried to optimize the worst cost which was a grep with a trivial regexp over around 1GB of data; I tried gawk, mawk, python, gnu grep, rg, ocaml and what struck me is that rg is faster than I am quickly able read the data from ocaml code: I tried Buffer.add_channel but it's almost twice slower, Unix.read but it's still slower
<adrien>
than rg but worse I get Bytes and I need String but Bytes.unsafe_to_string almost doubles the runtime
<adrien>
and I'm still not doing anything with what I read (I guess there could be some wins by not accumulating the data but I would still need a buffer to rebuild lines)
<adrien>
I know you can make cat very fast but without spending lots of time on that, what can I do?
<adrien>
at this point I'm very curious because I wasn't expecting to see such bottlenecks and I'm close to considering it a shift in how I view everyday performance
<duncan>
rg has a reputation for being faster than the gnu grep, IME it's not that much faster than grep(1) on the Mac or Solaris, YMMV
<duncan>
grep compared to awk and friends is dependent on context, they're not strictly replacements for each other and have worked fine for decades
rgrinberg has joined #ocaml
<duncan>
The other thing is that for really complicated tasks I would prioritise readability/understanding over speed. Computers are cheap, I don't do programming after 5pm, it's easy to leave something overnight and I get 10 hours of sleep a night.
<adrien>
I wanted to iterate on a program and to run it repeatedly; I have a number of long-running tasks and enough horsepower but here the question is how to be efficient with ocaml despite some of its abstractions
wagle has quit [Ping timeout: 256 seconds]
wagle has joined #ocaml
<discocaml>
<Ada> weird, ocurl is missing some CURLOPTs
wingsorc has joined #ocaml
motherfsck has quit [Quit: quit]
czy has quit [Remote host closed the connection]
meator has quit [Quit: WeeChat 4.1.2]
waleee has quit [Ping timeout: 245 seconds]
rak has quit [Ping timeout: 256 seconds]
trev has quit [Quit: trev]
waleee has joined #ocaml
waleee has quit [Ping timeout: 260 seconds]
dnaq has quit [Remote host closed the connection]
rak has joined #ocaml
dnaq has joined #ocaml
oriba has joined #ocaml
waleee has joined #ocaml
<adrien>
I think what I'm looking for is vmsplice() but it's inconvenient with ocaml values I guess (since there is a header and you can't really page-align due to it) and it's not a clean map with ocaml types probably
<adrien>
but extunix has it
neiluj has joined #ocaml
<adrien>
except I still won't have a string afterwards
<adrien>
well, there's get_substr but I guess it involves copying data
Serpent7776 has quit [Ping timeout: 268 seconds]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
neiluj has quit [Quit: neiluj]
bartholin has quit [Quit: Leaving]
rgrinberg has joined #ocaml
Tuplanolla has quit [Quit: Leaving.]
<discocaml>
<darrenldl> adrien: what kind of data and are you on release build?
<discocaml>
<darrenldl>
<discocaml>
<darrenldl> rg is really optimised still, so i wouldnt be surprised if it's faster even with a regex
<companion_cube>
adrien: Bytes.unsafe_of_string should be a no op