tautologico has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troutwine is now known as troutwine_away
dotfelix has quit [Client Quit]
dotfelix has joined #ocaml
yomimono has joined #ocaml
struktured has joined #ocaml
<yomimono>
where can I find documentation on directives in utop?
dotfelix has quit [Quit: Leaving]
<yomimono>
specifically, I want to get more output on what's actually going on when I #require something
mort___ has quit [Ping timeout: 240 seconds]
q66 has quit [Quit: Leaving]
hausdorff has quit [Remote host closed the connection]
penglingbo has joined #ocaml
shinnya has quit [Ping timeout: 240 seconds]
struktured has quit [Read error: Connection reset by peer]
hausdorff has joined #ocaml
hausdorff has quit [Read error: Connection reset by peer]
hausdorff has joined #ocaml
tautologico has joined #ocaml
<tautologico>
I'm building a lib as a shared library to use as a plugin, but this plugin depends on another findlib package... when I try to use the plugin the program can't find the symbols for the package my plugin depends on. anyway to link everything in a single .cmxs?
<Drup>
huum, -link-all ?
<Drup>
(not sure)
<tautologico>
seems to work, now I get a segfault
<Drup>
a segfault O_o
<Drup>
due to what ?
troutwine_away is now known as troutwine
ygrek has joined #ocaml
<tautologico>
I have no idea
troutwine is now known as troutwine_away
<mfp>
tautologico: this and other fun things can happen if you link a module twice (e.g. Unix, once in the main program, another in the .cmxs)
Eyyub has quit [Ping timeout: 260 seconds]
englishm1 has quit [Quit: Leaving.]
english__ has quit [Remote host closed the connection]
tautologico has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hausdorff has quit [Remote host closed the connection]
hausdorff has joined #ocaml
hausdorff has quit [Remote host closed the connection]
hausdorff has joined #ocaml
johnnydiabetic has joined #ocaml
englishm has joined #ocaml
englishm_ has joined #ocaml
englishm has left #ocaml [#ocaml]
tautologico has joined #ocaml
philtor has joined #ocaml
philtor has quit [Ping timeout: 260 seconds]
philtor has joined #ocaml
bjorkintosh has quit [Ping timeout: 245 seconds]
bjorkintosh has joined #ocaml
arquebus has joined #ocaml
tautologico has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troutwine_away is now known as troutwine
sad0ur has quit [Read error: No route to host]
sad0ur has joined #ocaml
troutwine is now known as troutwine_away
yomimono has quit [Quit: Leaving]
hausdorff has quit [Remote host closed the connection]
hausdorff has joined #ocaml
hausdorff has quit [Remote host closed the connection]
jao has quit [Ping timeout: 245 seconds]
philtor has quit [Ping timeout: 250 seconds]
arquebus has quit [Quit: Konversation terminated!]
hausdorff has joined #ocaml
WraithM has quit [Ping timeout: 260 seconds]
siddharthv_away is now known as siddharthv
pgomes has joined #ocaml
johnnydiabetic has quit [Ping timeout: 260 seconds]
sorabji has left #ocaml ["ERC Version 5.3 (IRC client for Emacs)"]
axiles has joined #ocaml
ddosia has quit [Quit: Leaving.]
ddosia has joined #ocaml
pgomes has quit [Quit: Leaving]
WraithM has joined #ocaml
hhugo has quit [Quit: Leaving.]
WraithM has quit [Ping timeout: 255 seconds]
WraithM has joined #ocaml
Simn has joined #ocaml
tidren has joined #ocaml
ollehar has joined #ocaml
troutwine_away is now known as troutwine
ygrek has quit [Ping timeout: 245 seconds]
hhugo has joined #ocaml
ollehar has quit [Ping timeout: 250 seconds]
troutwine is now known as troutwine_away
hhugo has quit [Client Quit]
ggole has joined #ocaml
seliopou has quit [Ping timeout: 240 seconds]
seliopou has joined #ocaml
ygrek has joined #ocaml
penglingbo has quit [Ping timeout: 255 seconds]
troutwine_away is now known as troutwine
zpe has joined #ocaml
tidren has quit [Remote host closed the connection]
tidren_ has joined #ocaml
troutwine is now known as troutwine_away
tidren_ has quit [Remote host closed the connection]
squiggnet_ has quit [Ping timeout: 240 seconds]
squiggnet has joined #ocaml
tidren has joined #ocaml
_0xAX has joined #ocaml
tidren has quit []
cago has joined #ocaml
WraithM has quit [Ping timeout: 255 seconds]
zpe has quit [Remote host closed the connection]
Eyyub has joined #ocaml
englishm_ has quit [Remote host closed the connection]
englishm has joined #ocaml
sagotch has joined #ocaml
troutwine_away is now known as troutwine
Hetu has joined #ocaml
BitPuffin has quit [Ping timeout: 245 seconds]
troutwine is now known as troutwine_away
BitPuffin has joined #ocaml
Eyyub has quit [Ping timeout: 256 seconds]
Kakadu has joined #ocaml
hausdorff has quit [Remote host closed the connection]
hausdorff has joined #ocaml
hausdorff has quit [Ping timeout: 240 seconds]
eikke__ has joined #ocaml
zpe has joined #ocaml
troutwine_away is now known as troutwine
sagotch has quit [Remote host closed the connection]
Averell has quit [Read error: Connection reset by peer]
troutwine is now known as troutwine_away
Eyyub has joined #ocaml
jonludlam has joined #ocaml
MercurialAlchemi has joined #ocaml
<MercurialAlchemi>
Hi folks
mingus has joined #ocaml
<MercurialAlchemi>
How do you implement something similar to try-with-resource in Ocaml?
mingus is now known as ewd
<def`>
1. let finalize f u = try let r = f () in u (); r with exn -> u (); raise exn
<def`>
so you have a finalize construct
<def`>
finally*
<def`>
2. let with_myresource r f = acquire r; finally f (fun () -> release r)
<def`>
3. with_myresource r (fun () -> bla bla bla)
<MercurialAlchemi>
ok, so it's not really built-in
<MercurialAlchemi>
no library does this?
<flux>
probably some do :-)
<def`>
some libraries do, if needed
<flux>
but what those patterns I always find lacking (for the general case) is the ability to not release the resource
<def`>
it's not built-in: no, it can be implemented with lower-level constructs ;)
<flux>
for example if you end up needing to put the resource away for use elsewhere
<def`>
yes, this construct ties the lifetime of a resource to the lexical scope
<flux>
I suppose a library with reference counter resource management would have an easy way out
Averell has joined #ocaml
<def`>
this become a problem with you have abstraction purposely allowing to escape the scope, like concurrency monad
<flux>
access_reference_counted_resource r (fun underlying_resource -> stash_away (resource_with_increased_reference_count r)) or something.
<def`>
flux: or just abstracting over a monad with a notion of scope exit (MonadPlus-like in haskell, though it's a bit too limited)
<MercurialAlchemi>
yes, in this case you'd need a stateful bona fide resource manager
<MercurialAlchemi>
which is kind of why I came here: the question struck while I was doing a CR dealing with such a beast (in Java)
<def`>
it depends on what you know about the lifetime of the resource
<def`>
the with_pattern* works if its lifetime is delimited to lexical scope.
<MercurialAlchemi>
absolutely
<MercurialAlchemi>
and in my experience, it's most often the case
<def`>
if you want completely dynamic lifetime, well you need a GC ;)
<MercurialAlchemi>
I'm fine with having constructs which work for the common case, which is why I'm a bit disappointed to be left with the impression that there isn't a built-in way of releasing a resource
<def`>
with a concurrency monad like Lwt or Async, you should be able to handle all cases, at the expenses of having your code injected into the monad
<def`>
MercurialAlchemi: I am not sure it would make sense, or it would be overly specific
<MercurialAlchemi>
def`: I was thinking of an analog to the 'with' construct in Python, which definitely makes a lot of sense
<def`>
I disagree.
<flux>
reference-counted GC just works much better for resources other than memory
<def`>
OCaml is expressive-enough to reimplement this notion in a convenient-way
<def`>
And we have different notion of scope, to 'with' in python-sense construct is too specific
<def`>
so 'with' construct as in python is too specific* Pfff, sorry
<MercurialAlchemi>
I don't think it's a questoin of expressivity, you can easily implement an equivalent to the 'with' idiom in Python
Anarchos has joined #ocaml
<MercurialAlchemi>
though it would be easier in ruby, I guess
yacks has quit [Ping timeout: 245 seconds]
<MercurialAlchemi>
the point is that including in the language makes it a standard, and means that you can close IMAP connections the same way as SQL connections if they have the right method
<def`>
when you to deal with resources, sockets, and so on, you're likely to be dealing with concurrency
yacks has joined #ocaml
<MercurialAlchemi>
to go back to your second point, and here I'm likely to betray the fact that I'm not that far into Real World Ocaml, I'm not sure of what you mean about scope being different between Python and OCaml (if you mean the Python scoping rules inside a function suck, I'm right there with you, but I don't think they're relevant in this case)
<MercurialAlchemi>
def`: sometimes
<def`>
MercurialAlchemi: my point is that to deal with concurrency, we usually abstract over the control-flow
<def`>
by intentionnally making values escape the "lexical scope" of the function (using closures), but relying on carefully crafted abstractions to keep things easy to manage
<MercurialAlchemi>
def`: I've written tons of single-threaded code where I was only interested in opening files A,B and C and ensuring that they got closed in the right order when leaving the function
<MercurialAlchemi>
def`: (after processing them)
<def`>
a 'with' construct baked into the language could'nt (easily) be aware of this broaded notion of control flow
<def`>
broader*
<def`>
MercurialAlchemi: then the two lines idiom I gave you is enough to deal with those cases
<MercurialAlchemi>
well, as far as I remember, Python has this exact issue wrt closures, but in many cases it's not a problem
<def`>
which issue?
<MercurialAlchemi>
that if your with block returns a closure containing your resource, you're going to have a bad surprise when you try to do anything with it, because it will be closed
<MercurialAlchemi>
but it's a dumb thing to do to start with
<MercurialAlchemi>
live by the sword, die by the sword
lgm has quit [Read error: Connection reset by peer]
<def`>
I don't know when RWO introduce Async, but you should at least get to this point before thinking of a "general" with-construct
<MercurialAlchemi>
My experience says such a thing is common enough to be standardized (on top of encouraging people to think about closing their resource), as long as the limitations are well-documented
<MercurialAlchemi>
but maybe I'll change my mind when I get a better idea of what idiomatic OCaml looks like
<flux>
maybe a debug-version of 'with' construct could use data dumping functionality to search the returned value for references to the resource ;-)
<def`>
:DD, or attach a finalizer to the resource, runs two full gc when exiting scope, and ensure that finalizer has been run properly
<flux>
well, that would typically be slower
<MercurialAlchemi>
lol
penglingbo has joined #ocaml
<MercurialAlchemi>
using a destructor in a gc language sounds like a bad plan
<def`>
php pages are expected to be short-lived, it sounds ok
<def`>
(otherwise, php as a whole is a bad idea ;))
<MercurialAlchemi>
Originally, I was under the impression that PHP was an illustration of the infinite monkey theorem
<MercurialAlchemi>
But the more I see of it, the more I think it's more a viral generator of jobs for the industry, due to the number of bad practices it encourages
<MercurialAlchemi>
Such an accumulation of appalling technical decisions cannot be random
troutwine_away is now known as troutwine
troutwine is now known as troutwine_away
ygrek has quit [Ping timeout: 250 seconds]
<Anarchos>
MercurialAlchemi we all have to keep our jobs ;)
<MercurialAlchemi>
Anarchos: yes, but languages where magic_quotes are not the gold standard of security make it harder than those who do
<Anarchos>
MercurialAlchemi sure
<MercurialAlchemi>
(I know, I know, it's not recommended anymore)
dsheets has joined #ocaml
dsheets has quit [Remote host closed the connection]
dsheets_ has joined #ocaml
ggole_ has joined #ocaml
ggole has quit [Ping timeout: 255 seconds]
Hetu has quit [Ping timeout: 264 seconds]
thomasga has joined #ocaml
hhugo has joined #ocaml
sagotch has joined #ocaml
<NoNNaN>
whitequark: is there any way to use GuaranteedTailCallOpt after llvm-3.4 ? The option moved to TargetOption::GuaranteedTailCallOpt, but it looks like the llvm-c api does not expose the TargetOption parameter on creation nor does the ocaml binding. the lib/Target/TargetMachineC.cpp -> LLVMCreateTargetMachine does not have the TargetOption parameter, is there any other way (api, anything) to enable it?
thomasga has quit [Quit: Leaving.]
_andre has joined #ocaml
yman has joined #ocaml
<yman>
Hi - From my OCaml application, I need to spawn a subprocess (with its own read-eval-print-loop) and communicate with it over time. I'm using Unix.open_process to get the in and out channels for the subprocess. But, when I use the input function in OCaml, it blocks when it has reached the end of the stream it's reading from. Is there an OCaml library that handles easily interacting with subprocesses?
<def`>
are you closing the output in the subprocess?
<yman>
Hmm, I don't think so - the subprocess is itself just presenting a read-eval-print-loop on its own stdin/stdout, and is designed for being used interactively in a terminal
maattdd has joined #ocaml
<yman>
(I am not the `owner' of the subprocess - it's a stand-alone tool )
<yman>
(I mean to say, I don't have access to the subprocess's source code)
<def`>
if you are finished using the process, you can close stdin
yman_ has joined #ocaml
<yman_>
Hi, I'm sorry, I disconnected and missed any replies you may have written.
siddharthv is now known as siddharthv_away
<def`>
if you are finished using the sub process, you can close its stdin
<def`>
maybe this will make it stop
<def`>
otherwise, you can use Unix.select with an appropriate timeout to see if the process wrote anything
<def`>
… but in general, there is a race condition: you can't tell if the process will write something in the future you might miss
<def`>
so you need a way to signal the end
yman has quit [Ping timeout: 246 seconds]
<yman_>
Hmm, tricky. I can perhaps rely on the fact that the subprocess presents its REPL prompt only once it's done with its output
<yman_>
So perhaps I should just keep using input until I encounter the prompt
<def`>
yes
<yman_>
Thank you about Unix.select - I will look into that, too
<def`>
that's what tools like expect does
<yman_>
Great, thank you
Eyyub has quit [Ping timeout: 255 seconds]
Hetu has joined #ocaml
sagotch has quit [Ping timeout: 250 seconds]
cago has quit [Ping timeout: 240 seconds]
agarwal1975 has quit [Quit: agarwal1975]
ggole_ is now known as ggole
rand000 has joined #ocaml
thomasga has joined #ocaml
freling has quit [Quit: Leaving.]
freling has joined #ocaml
maattdd has quit [Ping timeout: 255 seconds]
penglingbo has quit [Ping timeout: 250 seconds]
yman_ has quit [Ping timeout: 246 seconds]
darkf has quit [Quit: Leaving]
agarwal1975 has joined #ocaml
hhugo has quit [Quit: Leaving.]
englishm has quit [Ping timeout: 256 seconds]
hhugo has joined #ocaml
parcs has quit [Ping timeout: 272 seconds]
penglingbo has joined #ocaml
parcs has joined #ocaml
englishm has joined #ocaml
nlucaroni has joined #ocaml
Hetu has quit [Remote host closed the connection]
thomasga has quit [Quit: Leaving.]
englishm1 has joined #ocaml
sagotch has joined #ocaml
sagotch_ has joined #ocaml
craigglennie has joined #ocaml
sagotch has quit [Ping timeout: 260 seconds]
cago has joined #ocaml
thomasga has joined #ocaml
thomasga has quit [Client Quit]
ygrek has joined #ocaml
Eyyub has joined #ocaml
johnnydiabetic has joined #ocaml
<ewd>
how do you declare a function in a .mli file that return a type from a parametric module like a -> b Set?
<ewd>
so I need to kind of instanciate Set on the .mli
<ggole>
a -> Set.Make(...).t
<ggole>
Or you can give it a name
hhugo has quit [Quit: Leaving.]
<ewd>
ah ok, like type myset = Make(...).t?
<ggole>
No, the module that is the application of the Set functor
<ggole>
module Test : sig module S : Set.S with type elt = string val f : string -> S.t end = struct module S = Set.Make (String) let f x = ... end
<ewd>
ok
<ewd>
the last sounds a lot of boiler plate code
_0xAX has quit [Remote host closed the connection]
zpe has quit [Remote host closed the connection]
hhugo has joined #ocaml
Youri has quit [Ping timeout: 250 seconds]
Youri has joined #ocaml
sagotch_ has quit [Remote host closed the connection]
hausdorff has joined #ocaml
Youri has quit [Ping timeout: 264 seconds]
shinnya has joined #ocaml
maattdd has joined #ocaml
cago has quit [Ping timeout: 250 seconds]
jonludlam has quit [Ping timeout: 260 seconds]
jprakash has joined #ocaml
thomasga has joined #ocaml
craigglennie has quit [Quit: craigglennie]
hausdorff has quit [Remote host closed the connection]
hausdorff has joined #ocaml
hausdorff has quit [Ping timeout: 240 seconds]
George_ has joined #ocaml
craigglennie has joined #ocaml
englishm2 has joined #ocaml
englishm1 has quit [Read error: Connection reset by peer]
englishm has quit [Read error: Connection reset by peer]