<ggole>
Er, there should be an 'f' between output_string and "words", of course.
avsm has quit [Quit: Leaving.]
zacts has joined #ocaml
<watermind>
ggole: that really was confusing me :P
malo has quit [Quit: Leaving]
<caseyjames>
The real world ocaml exmaple worked, thanks for that. ggole, when I run yours, with the f, I get this error that I'm getting with all other file write examples I've found, is it a core thing? Error: This expression has type out_channel but an expression was expected of type [ `Deprecated_use_out_channel ] #
<ggole>
Yeah, that's a core thing
<watermind>
caseyjames: there was an f missing, see ggole's comment just above
<caseyjames>
yes i added it -> let f = open_out "foo" in output_string f "words"; close_out f
<watermind>
OK so I did the following. 1. compiled a.ml to bytecode, 2. loaded the cmo on utop 3. tried to use b.ml on utop, which requires a module in a.ml
<watermind>
shouldn't that ^ work?
qzmp has joined #ocaml
w0rm_x has quit [Ping timeout: 240 seconds]
<watermind>
caseyjames: right, Core removes some things, same with == and !=, it'll tell you it's deprecated
<whitequark>
==/!= are deprecated?..
<ggole>
Yes, that should work. You might need to fiddle with directories though.
<watermind>
whitequark: in core they use some other functions instead of those operators
<ggole>
If you are compiling things into _build, say.
<watermind>
whitequark: rational being that you may accidentally mistake != for <>
<watermind>
1 !=2;; "Error: This expression has type int but an expression was expected of type [ `Consider_using_phys_equal ]"
<watermind>
phys_equal is used instead
<watermind>
personally I like it
<qzmp>
Hi! I am doing homework, where i need to add item to list, but not on the begining, but on the end, as far as i know the only way to do this is to use "@", but the task says to write as optimal implementation as possible, and i read that adding item on the end of the list is slow, is there anothere way to do this?
<mrvn>
qzmp: add them at the front and at the end reverse the result.
<whitequark>
I used = instead of == so much, and vice versa too, and for != too
<watermind>
yeap
<ggole>
Yeah, I've had the same experience
<whitequark>
(Ruby uses == for equality and .equal? for physical one)
<ggole>
Occasionally an infloop from using = instead of ==, too
<qzmp>
mrvn: if i can't use reverse, is "@" optimal way to do this? because i think i relly cant use reverse
<ggole>
@ is linear in the length of its first argument (the one on the left).
<ggole>
So don't go calling it in a loop.
<mrvn>
yes. Unless you use Obj.magic. But you can always reverse
Anarchos has joined #ocaml
Kakadu has joined #ocaml
<watermind>
wait
mort___ has joined #ocaml
<watermind>
so after loading a .cmo can I or cannot I access the respective module?
<watermind>
#load "src/a.ml" ;;
<watermind>
ops
<watermind>
#load "src/a.cmo" ;;
<watermind>
now what?
<adrien>
cmi must be in search path
<ggole>
A.foo some_arg should then work (if your directories are right)
<watermind>
adrien: hmmm I see
Yoric has quit [Ping timeout: 268 seconds]
<watermind>
so I definitely need to setup an ocaml makefile
<adrien>
or use "ocaml -I src"
<watermind>
right
* adrien
-> bed
<ggole>
Or put #directory "src" in .ocamlinit
<watermind>
good night, thanks
<watermind>
ggole: oh
<ggole>
(Keep in mind that will hide the effect of any ~/.ocamlinit)
<watermind>
right
avsm has joined #ocaml
asmanur_ has quit [Ping timeout: 260 seconds]
<watermind>
so, if I understand, this will give me access only to the exported functions in the interface
<ggole>
Yep
<watermind>
so how do you usually test during development? keep a temporary interface exporting everything?
<mrvn>
watermind: you add unit tests to the modules itself
<ggole>
Tests that need access to internals fundamentally need to be within the module in question.
<watermind>
mrvn: ggole: right all that makes sense.
stevej has joined #ocaml
avsm has quit [Client Quit]
<watermind>
mrvn: ggole: I'm used to, mainly during early development, experiment in the interpreter as I develop though
<ggole>
Yep, that's natural
<ggole>
I think it's fairly common to leave the .mli until a module is somewhat developed.
<watermind>
right
<ggole>
So you get easy access to all the bits.
<ggole>
Another approach is to load the source of a module into the toplevel directly
<watermind>
ggole: that's what I was thinking, but can it be done if there are dependencies?
<ggole>
Yes
<ggole>
Of course, you have to get all the bits into place.
<watermind>
right, for a moment i thought we couldn't load the dependency cmo and than use the dependent file
<ggole>
Well, usually you would have the build system create a working toplevel for you, rather than loading .cmos by hand
<ggole>
But doing it manually a few times until you understand what's going on is probably a good thing.
madroach has quit [Ping timeout: 264 seconds]
<watermind>
ggole: yeap, I just wanted to get a feel for what's happening before I automate the process
caseyjames has quit [Ping timeout: 250 seconds]
nikki93 has joined #ocaml
avsm has joined #ocaml
ggole has quit []
Arsenik has joined #ocaml
wolfnn has joined #ocaml
avsm has quit [Quit: Leaving.]
Yoric has joined #ocaml
darkf has joined #ocaml
avsm has joined #ocaml
<watermind>
ok so back to trying to work with two files...
<watermind>
so from what I understood I could use 3 approaches: 1. specify the approriate dirs in .ocamlinit, 2. use a flag in the top-level to specify the dirs 3. use the build system to create a working toplevel
stevej has quit [Ping timeout: 268 seconds]
<watermind>
1. is not a good idea, since I'd lose ~/.ocamlinit...
<watermind>
2. I was told -l but no such flag is recognised by ocaml/utop and can't find any other
<rks`>
-I
<watermind>
3. I don't fully understand the connection... a build system builds... I can build it by hand... how does that relate to create a working top level
<rks`>
not -l, -i (uppercased)
<watermind>
oh damn font
Anarchos has quit [Quit: must reboot on win7 to debug epson printer]
<watermind>
rks`: thanks you! I was trying to search for it, but was a bit lost with documentation about all sorts of build systems for ocaml
<rks`>
:)
stevej has joined #ocaml
_andre has quit [Quit: leaving]
<watermind>
using -I did the trick, ocamlmktop for some reason isn't working, it does create the toplevel, but then returns unbound module when trying to open
<watermind>
even tried ocamlmktop -o test -I _build/src/ _build/src/arith.cmo
<watermind>
in case the -I was still required for it to know about the mli
stevej has quit [Ping timeout: 260 seconds]
ocp has joined #ocaml
q66 has joined #ocaml
maurer has joined #ocaml
nikki93 has quit [Remote host closed the connection]
ohama has quit [Ping timeout: 240 seconds]
<watermind>
is omake the de facto standard for building OCaml projects?
<companion_cube>
there is no standard, sadly
steshaw has joined #ocaml
<companion_cube>
some use ocamlbuild, some other omake, jenga, ocp-build...
<watermind>
right
<companion_cube>
I'm tending towards oasis+ocamlbuild
<companion_cube>
so if some system wins the war, updating to it will take one line ;)
<watermind>
:)
<def-lkb>
In my view, ocamlbuild is more suited for small projects. omake & jenga for big ones. I never tried ocp-build.
<watermind>
I've been using ocamlbuild, but just command line
<companion_cube>
I use a small makefile + ocamlbuild, or makefile + oasis -> ocamlbuild
<ocp>
I use ocp-build :-)
<companion_cube>
oasis is actually pretty neat for medium projects
<companion_cube>
ocp: what a surprise :]
<companion_cube>
btw, I was wondering whether the DHT code of mldonkey was easy to extract as a library
<ocp>
maybe I should write some documentation, it would make using it a bit easier...
<ocp>
it used to be
<ocp>
oups, 2 discussions clashing
<ocp>
documenting ocp-build
<ocp>
and the DHT code of mldonkey used to be modular
<def-lkb>
Was ocp-build officially announced ?
maurer has left #ocaml []
<def-lkb>
(`officially' as in `on the ML' :))
<companion_cube>
on the ML donkey?
<ocp>
no, of course
<ocp>
I am still not completely sure about the description language
<ocp>
but the "next" branch in GIT is close to something that could be officially announced
nikki93 has joined #ocaml
<def-lkb>
Ok, that's nice to hear. I will wait for some official release
<watermind>
if makefile + ocamlbuild is a possibility, does this mean omake + ocamlbuild is also sensible? or am I getting my tools confused here?
<ocp>
yes, maybe a christmas gift :-)
<companion_cube>
ocp: it used to be modular, and then some evil commit happened? :)
<whitequark>
watermind: btw you can just use ocamlbuild without makefiles.
<ocp>
no, I just stopped maintaining it 8 years ago
<companion_cube>
I see
<ocp>
maybe ygrek would know
<companion_cube>
I suppose nowadays you would use async/lwt to write the network part, if you were to write it again
<ocp>
but writting DHT code in OCaml is quite easy, just need to take an academic paper and write the corresponding code
ohama has joined #ocaml
<watermind>
whitequark: right, I understand
<ocp>
no, I still prefer mldonkey's socket library
stevej has joined #ocaml
<companion_cube>
ocp: was it non-blocking?
<watermind>
whitequark: so you'd build a script to run ocamlbuild and to make a toplevel with the appropriate bytecode?
<ocp>
I don't like the idea that you can switch to another handler in the middle of a computation
<companion_cube>
I find network code is difficult to write in a very different way than symbolic computation code
<ocp>
let's say that lwt/async are better for performance, mldonkey's library is nice for writing sequential code
tani has quit [Quit: Verlassend]
<ocp>
in the handlers
<ocp>
well, also, it is completely non-documented, so you using lwt/async is clearly a better choice !
<watermind>
whitequark: I'm just trying to figure out the simplest way of working with small projects, e.g. say 5 or 6 files max... with haskell, I just ghci any file and it loads it in the interpreter, or ghc --make to compile it
<companion_cube>
besides, I suppose it was some UDP-based kademlia implementation
<companion_cube>
doesn't look easy...
<watermind>
whitequark: with ocaml right now I'm "ocamlbuilding it" then running top level, then loading cmo's, than using the file I want to edit
<watermind>
whitequark: and everytime I edit a dependency I redo the process
<watermind>
I really should move towards automating this
<watermind>
but I also don't need an "industrial solution"
stevej has quit [Read error: Connection reset by peer]
qzmp has quit [Quit: Page closed]
wmeyer has left #ocaml []
<whitequark>
watermind: oh, you need a toplevel... I never did that, let me look it up
<companion_cube>
watermind: so, a .ocamlinit file could'nt do with the "loading cmo and #use" part?
<whitequark>
watermind: looks like you need to make a foo.mltop file, enumerate all the modules you want to build in there, and then just ocamlbuild -use-ocamlfind foo.top
<whitequark>
simple enough to not need a makefile at all.
<watermind>
whitequark: well it's handy... rks` already showed me how to build a custom toplevel which is handy
<watermind>
companion_cube: I guess so, that is a possibility... I have to copy my ~/.ocamlinit for any project of mine, and add on that though (I'm using core) but it is a solution
<watermind>
companion_cube: I thought .oca,linit was meant to just have external dependencies for your project (e.g. packages like core) and not to be edited as you add your own files to the project
<companion_cube>
you do what you want with .ocamlinit! :)
<companion_cube>
(if you don't, I also suggest you use utop)
Kakadu has quit []
<watermind>
companion_cube: that looks nice
<watermind>
companion_cube: yes I just started using utop today... that was a big change!
<watermind>
merlin and autocomplete made a big difference too
<companion_cube>
yeah
<watermind>
what is that #install_printer directive, or better yet, where can I find out about them? I looked at https://github.com/diml/utop but couldn't find anything
stevej has joined #ocaml
<companion_cube>
it's a standard feature of ocaml
<companion_cube>
it installs custom pretty printers for some types
<companion_cube>
this type will be printed by your function rather by its generic structure
<watermind>
I see
<companion_cube>
it accepts function of type Format.formatter -> t -> unit, where t is your type
stevej has quit [Read error: Connection reset by peer]
w0rm_x has joined #ocaml
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
w0rm_x has quit [Client Quit]
w0rm_x has joined #ocaml
stevej has joined #ocaml
mort___ has quit [Quit: Leaving.]
stevej has quit [Client Quit]
swistak35 has joined #ocaml
stevej has joined #ocaml
gour has quit [Quit: WeeChat 0.4.1]
thomasga has joined #ocaml
thomasga has quit [Client Quit]
Yoric has quit [Ping timeout: 245 seconds]
avsm has quit [Quit: Leaving.]
steshaw has quit [Ping timeout: 272 seconds]
watermind has quit [Read error: Connection reset by peer]
watermind has joined #ocaml
Yoric has joined #ocaml
avsm has joined #ocaml
MoHaX has joined #ocaml
manizzle has joined #ocaml
Arsenik has quit [Ping timeout: 245 seconds]
Simn has quit [Read error: Connection reset by peer]
stevej has quit [Quit: Computer has gone to sleep.]
Yoric has quit [Ping timeout: 260 seconds]
manud_ has joined #ocaml
flx_ has joined #ocaml
stevej has joined #ocaml
flx_ is now known as Guest22718
flux has quit [Read error: Connection reset by peer]
Guest22718 is now known as flux
manud has quit [Ping timeout: 245 seconds]
lopex has quit [Ping timeout: 245 seconds]
manud_ is now known as manud
stevej has quit [Client Quit]
stevej has joined #ocaml
stevej has quit [Client Quit]
stevej has joined #ocaml
stevej has quit [Client Quit]
MoHaX has quit [Ping timeout: 272 seconds]
stevej has joined #ocaml
ollehar has quit [Ping timeout: 272 seconds]
stevej has quit [Read error: Connection reset by peer]
MoHaX has joined #ocaml
nikki93 has quit [Remote host closed the connection]
caseyjames has joined #ocaml
<caseyjames>
Does anyone have experience with mapping over SELECT results from sqlite3?
MoHaX has quit [Ping timeout: 260 seconds]
ontologiae has joined #ocaml
stevej has joined #ocaml
nikki93 has joined #ocaml
nikki93 has quit [Remote host closed the connection]
MoHaX has joined #ocaml
Drup has joined #ocaml
MoHaX has quit [Ping timeout: 245 seconds]
<dsheets_>
Is there an easy way to map between fds and ints in ocaml?
q66 has quit [Quit: Leaving]
mfp has quit [Ping timeout: 248 seconds]
<dsheets_>
Unix.file_descr seems too abstract to give one access to the fd int
<dsheets_>
but sometimes it is necessary to serialize/deserialize an fd for ipc
steshaw has joined #ocaml
<pippijn>
magic
<dsheets_>
pippijn, i feared as much
<dsheets_>
or, a C binding, I suppose, eh?
nikki93 has joined #ocaml
<Drup>
*purple* magic :]
ontologiae has quit [Ping timeout: 245 seconds]
avsm has quit [Quit: Leaving.]
avsm has joined #ocaml
<pippijn>
dsheets_: Unix.file_descr are just fds on unix
<dsheets_>
pippijn, it makes me nervous
<pippijn>
yes, it should
avsm has quit [Ping timeout: 268 seconds]
MoHaX has joined #ocaml
stevej has quit [Quit: Computer has gone to sleep.]
ontologiae has joined #ocaml
nikki93 has quit [Remote host closed the connection]