<dxtr>
It feels stupid to have a Lwt.t in my state record and it also feels stupid to force every function that wants to get some data from the state to use Lwt.bind
kakadu has quit [Remote host closed the connection]
<octachron>
dxtr, depending on the situation it might work better to have a "state Lwt.t" rather than an 'a Lwt.t in the state
<dxtr>
That means almost everything will have to use Lwt.bind
<octachron>
in fact, it is often possible to separate functions that manipulate the state into those that don't need to be aware of the 'a Lwt.t wrapping
<octachron>
and those that does affect the control flow and need to use bound
<octachron>
*bind
<dxtr>
hmm, okay
swalk has quit [Quit: swalk]
<octachron>
otherwise going back from 'a Lwt.t to 'a is possible with Lwt_main.run x, but that will call Lwt scheduler until the promise "x" is realized
swalk has joined #ocaml
swalk has quit [Quit: swalk]
pierpa has quit [Quit: Page closed]
mengu has quit [Remote host closed the connection]
al-damiri has joined #ocaml
swalk has joined #ocaml
seangrove has quit [Ping timeout: 248 seconds]
mfp__ has quit [Ping timeout: 248 seconds]
kalio has quit [Ping timeout: 240 seconds]
jlam_ has joined #ocaml
jlam__ has quit [Ping timeout: 240 seconds]
kalio has joined #ocaml
<cmk_zzz>
Newbie question. I have a list of key-value tuples where the value can be either a string or an int. Am I correct that I need to use sum type to handle this? I.e [ ("key", String "value"), ("key2", Int 3) ]. Ideally I'd like to just do [ ("key", "string"), ("key2", 3) ] and match on type like match (_, v) with | x when is_integer(x) | x when is_string(x)
<Armael>
you need a sum type. Types do not exist at run-time, they are used to check the program then erased when compiling
<Armael>
so you have no way of checking the type of x at runtime (so, no is_integer(x) or is_string(x))
<cmk_zzz>
Armael: thanks, that is what I thought.
jlam_ has quit [Ping timeout: 260 seconds]
jlam__ has joined #ocaml
jlam_ has joined #ocaml
jlam__ has quit [Ping timeout: 260 seconds]
cranmax has quit [Quit: Connection closed for inactivity]
mengu has joined #ocaml
mengu has quit [Ping timeout: 248 seconds]
jlam__ has joined #ocaml
jlam_ has quit [Ping timeout: 240 seconds]
enterprisey has joined #ocaml
silver has quit [Read error: Connection reset by peer]
groovy2shoes has quit [Ping timeout: 246 seconds]
groovy2shoes has joined #ocaml
swalk has quit [Quit: swalk]
yegods has quit [Remote host closed the connection]
mengu has joined #ocaml
SomeDamnBody has quit [Remote host closed the connection]
mengu has quit [Ping timeout: 240 seconds]
dreadedfrog has joined #ocaml
dreadedfrog has quit [Ping timeout: 240 seconds]
enterprisey has quit [Remote host closed the connection]
MercurialAlchemi has joined #ocaml
jlam_ has joined #ocaml
jlam__ has quit [Ping timeout: 248 seconds]
sam____ has joined #ocaml
lostman has joined #ocaml
sam____ has quit [Ping timeout: 240 seconds]
maarhart_ has joined #ocaml
maarhart_ has quit [Client Quit]
ryanartecona has joined #ocaml
jimmyrcom has quit [Ping timeout: 240 seconds]
mengu has joined #ocaml
mengu has quit [Ping timeout: 260 seconds]
MercurialAlchemi has quit [Ping timeout: 240 seconds]
enterprisey has joined #ocaml
jao has quit [Ping timeout: 240 seconds]
ryanartecona has quit [Quit: ryanartecona]
zwild has joined #ocaml
al-damiri has quit [Quit: Connection closed for inactivity]
MercurialAlchemi has joined #ocaml
sam____ has joined #ocaml
sam____ has quit [Ping timeout: 240 seconds]
Simn has joined #ocaml
mengu has joined #ocaml
mengu has quit [Ping timeout: 260 seconds]
demonimin has quit [Ping timeout: 240 seconds]
freusque has joined #ocaml
zwild has quit [Remote host closed the connection]
soupault has joined #ocaml
dakk has joined #ocaml
sam____ has joined #ocaml
demonimin has joined #ocaml
soupault has quit [Remote host closed the connection]
peterpp__ has joined #ocaml
peterpp__ has quit [Ping timeout: 240 seconds]
samrat_ has joined #ocaml
freusque has quit [Quit: WeeChat 1.9]
freusque has joined #ocaml
<reynir>
Is getpass available somewhere?
zpe has joined #ocaml
infinity0 has quit [Remote host closed the connection]
infinity0 has joined #ocaml
Algebr has quit [Ping timeout: 240 seconds]
jimt_ is now known as jimt
mengu has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
enterprisey has quit [Read error: Connection reset by peer]
mengu has quit [Ping timeout: 268 seconds]
zpe has quit [Ping timeout: 240 seconds]
lostman has quit [Quit: Connection closed for inactivity]
mfp__ has joined #ocaml
kakadu has joined #ocaml
Algebr has joined #ocaml
<Leonidas>
dxtr: I think the Lwt.t is by design. It is like the IO monad in Haskell and signals that this is depending on side-effects.
kakadu_ has joined #ocaml
kakadu has quit [Ping timeout: 255 seconds]
Algebr has quit [Remote host closed the connection]
Algebr has joined #ocaml
Algebr has quit [Read error: Connection reset by peer]
sam____ has quit [Ping timeout: 255 seconds]
samrat_ has quit [Ping timeout: 255 seconds]
Algebr has joined #ocaml
dreadedfrog has joined #ocaml
sam____ has joined #ocaml
mengu has joined #ocaml
mengu has quit [Ping timeout: 240 seconds]
sam____ has quit [Ping timeout: 246 seconds]
argent_smith has joined #ocaml
sam____ has joined #ocaml
cthuluh has quit [Ping timeout: 260 seconds]
cthuluh has joined #ocaml
andreas_ has joined #ocaml
samrat has joined #ocaml
ziyourenxiang has joined #ocaml
ziyourenxiang has quit [Changing host]
ziyourenxiang has joined #ocaml
Algebr has quit [Ping timeout: 255 seconds]
ziyourenxiang has quit [Quit: Leaving]
ziyourenxiang has joined #ocaml
al-damiri has joined #ocaml
mengu has joined #ocaml
mengu has quit [Remote host closed the connection]
mengu has joined #ocaml
samrat has quit [Ping timeout: 260 seconds]
ziyourenxiang has quit [Quit: Leaving]
ziyourenxiang has joined #ocaml
FreeBirdLjj has joined #ocaml
Algebr has joined #ocaml
freusque has quit [Quit: WeeChat 1.9]
FreeBirdLjj has quit [Ping timeout: 246 seconds]
freusque has joined #ocaml
sam____ has quit [Ping timeout: 260 seconds]
magistr has joined #ocaml
magistr has left #ocaml [#ocaml]
freusque has quit [Quit: WeeChat 1.9]
govg has quit [Ping timeout: 240 seconds]
freusque has joined #ocaml
govg has joined #ocaml
swalk has joined #ocaml
govg has quit [Ping timeout: 240 seconds]
malina has joined #ocaml
govg has joined #ocaml
jao has joined #ocaml
sam____ has joined #ocaml
jao has quit [Ping timeout: 260 seconds]
swalk has quit [Quit: swalk]
cow-orke1 is now known as cow-orker
aantron_ has joined #ocaml
<aantron_>
dxtr: typically something like a state shouldn't have any Lwt.t in it, Lwt.t means the user of a value might have to wait to get the value
<aantron_>
instead you'd have a bunch of transition functions that manipulate state. the ones that are pure would return state (... -> state), and the ones that might involve waiting (doing I/O) would return state Lwt.t (... -> state Lwt.t)
<aantron_>
as octachron suggested
<aantron_>
you would call the first group of functions at any time, but the second group of functions would be composed in whatever section of your program is doing I/O
jlam__ has joined #ocaml
<aantron_>
computing something from a state that doesn't involve any more I/O would be a function state -> ... that does not end in Lwt.t, so no need for bind there
jlam_ has quit [Ping timeout: 260 seconds]
jlam_ has joined #ocaml
<aantron_>
as Leonidas said, _ Lwt.t is like a type tag saying that computing a value might involve I/O, so you want to factor a bunch of your code into "pure" functions (with respect to I/O)
nightmared has quit [Quit: WeeChat 1.9]
<companion_cube>
but you can also put a 'a Lwt.t into a struct, as a kind of 'lazy' ;)
nightmared has joined #ocaml
<aantron_>
yep, in the end an _ Lwt.t is a promise, so you can have data structures including some promises, or consisting entirely of promises (e.g. if you want to wait on a list of them)
jlam__ has quit [Ping timeout: 255 seconds]
<aantron_>
but then you will get the Lwt.t type taint in any code that further uses those _ Lwt.ts, exactly because forcing the "lazy" might require waiting for I/O, if it's not yet fully computed
lostman has joined #ocaml
Algebr has quit [Remote host closed the connection]
Algebr has joined #ocaml
malina has quit [Remote host closed the connection]
jlam__ has joined #ocaml
jlam_ has quit [Ping timeout: 255 seconds]
two_wheels has joined #ocaml
two_wheels has quit [Client Quit]
al-damiri has quit [Quit: Connection closed for inactivity]
tcc[m] has quit [Quit: Bridged client killed]
mengu has quit [Remote host closed the connection]
jlam_ has joined #ocaml
jlam__ has quit [Ping timeout: 248 seconds]
mengu has joined #ocaml
aantron_ has quit [Remote host closed the connection]
aantron_ has joined #ocaml
mengu has quit [Ping timeout: 240 seconds]
whoman has joined #ocaml
flo2 has joined #ocaml
<flo2>
is this the correct way to configure ocaml without the skylake cpu bug, ./configure -cc gcc -fno-tree-vrp
<Leonidas>
ocaml has no skylake bug, I'd rather configure the Intel CPU not to have it.
swalk has joined #ocaml
two_wheels has joined #ocaml
<flo2>
Leonidas: it appears in OCaml due to the GCC generated code, so appearantly this can prevent this code from being generated. I am just concerned about the correct way to pass the arguments
<Leonidas>
flo2: don't you have the possibility to pass in the microcode update? that would fix things for all applications.
<flo2>
Leonidas: No i dont, thats why i am asking for the correct way to configure ocaml
sh0t has joined #ocaml
sam____ has quit [Ping timeout: 240 seconds]
jlam_ has quit [Ping timeout: 255 seconds]
jlam_ has joined #ocaml
<flo2>
Did someone here did that?
<dxtr>
aantron_: Actually my "state" isn't a "state" per se but it's a record that contains the database handle and some settings that I am acquiring from the database
<kakadu_>
flo2: I heard that you need clang, don't you?
<dxtr>
And this is never modified
<dxtr>
Actually, the database pool
<dxtr>
I'm creating a Lwt_pool
<Fardale>
flo2: MPR#7452, GPR#1228: tweak GCC options to try to avoid the
<Fardale>
Skylake/Kaby lake bug
<Fardale>
this is in the release note of 4.05.0
<dxtr>
Guess I could fetch that without Lwt
<Fardale>
So if you can install the 4.05.0 version of ocaml you don't have to do anything
<flo2>
Fardale: yes, but this also affects 4.03 OCaml runtime. Thats why i ask if i set the configure correctly
swalk_ has joined #ocaml
Algebr has quit [Ping timeout: 246 seconds]
<flo2>
is this better suited on the ocaml mailing list?
swalk has quit [Ping timeout: 240 seconds]
swalk_ is now known as swalk
MercurialAlchemi has quit [Ping timeout: 240 seconds]
jlam__ has joined #ocaml
jlam_ has quit [Ping timeout: 248 seconds]
aciniglio has joined #ocaml
sam____ has joined #ocaml
sam____ has quit [Ping timeout: 260 seconds]
ryanartecona has joined #ocaml
nullx002 has quit [Ping timeout: 255 seconds]
mengu has joined #ocaml
nullx002 has joined #ocaml
maarhart_ has joined #ocaml
maarhart_ has quit [Remote host closed the connection]
jao has joined #ocaml
aantron_ has quit [Remote host closed the connection]
aantron_ has joined #ocaml
freusque has quit [Quit: WeeChat 1.9]
jimmyrcom has joined #ocaml
zpe has joined #ocaml
FreeBirdLjj has joined #ocaml
slash^ has joined #ocaml
silver has joined #ocaml
sam____ has joined #ocaml
pacak has quit [Ping timeout: 246 seconds]
sam____ has quit [Ping timeout: 276 seconds]
mengu has quit [Quit: Leaving...]
iitalics has joined #ocaml
sparkyy_ has joined #ocaml
pacak has joined #ocaml
sparkyy has quit [Ping timeout: 248 seconds]
aciniglio has quit [Read error: Connection reset by peer]
enterprisey has joined #ocaml
jao has quit [Ping timeout: 240 seconds]
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
enterprisey has quit [Remote host closed the connection]
zpe has quit [Ping timeout: 240 seconds]
sam____ has joined #ocaml
sam____ has quit [Ping timeout: 240 seconds]
zpe has joined #ocaml
sveit has joined #ocaml
johnelse has quit [Ping timeout: 260 seconds]
johnelse has joined #ocaml
samrat has joined #ocaml
ryanartecona has quit [Quit: ryanartecona]
_andre has quit [Read error: Connection reset by peer]
_andre has joined #ocaml
sz0 has joined #ocaml
maxton_ has joined #ocaml
aantron_ has quit [Remote host closed the connection]
aantron_ has joined #ocaml
kalio has quit [Quit: WeeChat 1.9]
aantron_ has quit [Client Quit]
kalio has joined #ocaml
tane has joined #ocaml
andreas_ has quit [Quit: Connection closed for inactivity]
whoman has quit [Quit: Leaving]
samrat has quit [Ping timeout: 246 seconds]
sam____ has joined #ocaml
ygrek has joined #ocaml
sam____ has quit [Ping timeout: 276 seconds]
MercurialAlchemi has joined #ocaml
TheLemonMan has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
ryanartecona has joined #ocaml
zpe has quit [Remote host closed the connection]
zpe has joined #ocaml
FreeBirdLjj has joined #ocaml
aantron_ has joined #ocaml
aantron_ has quit [Client Quit]
aantron_ has joined #ocaml
<aantron_>
dxtr: it's hard to say without seeing code what's going on. in my experience, lwt (and i suppose async) doesn't get in the way, rather it helps you to be very aware of when you might have to wait. so if you have a Lwt.t where you don't want one, it usually implies some mismatch between expectations about (not) waiting, and what the code you are calling might actually do
<aantron_>
that said, you can get an 'a out of an 'a Lwt.t by doing something like "match Lwt.state p with | Lwt.Return v -> v | _ -> assert false". i don't recommend actually doing this, though :)
<dxtr>
I can definitely show you the code if you feel like flinging some poop my way :)
<dxtr>
I realized I might be thinking about this the wrong way
sam____ has joined #ocaml
<aantron_>
sure. if you are editing it now because of that, maybe it's better to look later - but i can certainly glance at it and give some impressions :)
<dxtr>
I am not
swalk has quit [Ping timeout: 240 seconds]
<dxtr>
Been taking the kids all day. Just say down
zpe has quit [Remote host closed the connection]
<dxtr>
s/say/say/
<dxtr>
Haha
<dxtr>
Typing is difficult
<aantron_>
:D
<dxtr>
The buttons are like right next to each other
<dxtr>
yeah, that version of the file actually seems to compile (Nevermind that other parts of the project isn't compiling yet)
<Armael>
is Lwt_PGOCaml.prepare returning a unit Lwt.t? If so you should'nt be ignoring it
zpe has quit [Ping timeout: 248 seconds]
<Armael>
(ignoring a unit Lwt.t means you're dropping the promise on the floor, it's not even required to run)
<dxtr>
Armael: That's only there to get it to compile right now. I'm not even sure I want them there :)
<dxtr>
but yeah, thanks for the heads up
<Armael>
the fix is simply to bind on it instead
<Armael>
lw
<Armael>
(oops)
<Armael>
Lwt_PGOCaml.prepare ... >>= fun () -> ...
<dxtr>
Right
<dxtr>
Also, the "issue" I am having problems wrapping my head around is in src/markov.ml
<dxtr>
The init function
<dxtr>
The problem is that I want to fetch some stuff from the database and stick it in my record
<dxtr>
I figure I have to options: 1) Don't use LWT in the init function 2) Break out the lwt stuff from the database functions and leave that to the caller
<dxtr>
two options even
jao has joined #ocaml
<dxtr>
Also, I realized why I had `module PGOCaml = Lwt_PGOCaml` in markov_db - PGSQL seems to assume that that's the name of the module to use
MercurialAlchemi has quit [Ping timeout: 240 seconds]
shepard has joined #ocaml
enterprisey has joined #ocaml
<aantron_>
dxtr: will look shortly, writing a release announcement :)
ollehar has joined #ocaml
<dxtr>
What are we releasing?
tane has quit [Quit: Leaving]
MercurialAlchemi has joined #ocaml
aantron_ has quit [Remote host closed the connection]
enterprisey has quit [Ping timeout: 268 seconds]
aantron_ has joined #ocaml
iitalics has quit [Quit: /thread]
aciniglio has joined #ocaml
sam____ has quit [Ping timeout: 240 seconds]
ryanartecona has quit [Quit: ryanartecona]
enterprisey has joined #ocaml
ryanartecona has joined #ocaml
yegods_ has joined #ocaml
slash^ has quit [Read error: Connection reset by peer]
MercurialAlchemi has quit [Ping timeout: 255 seconds]
FreeBirdLjj has quit [Remote host closed the connection]
yegods_ has quit []
jlam_ has joined #ocaml
jlam__ has quit [Ping timeout: 255 seconds]
jlam__ has joined #ocaml
<aantron_>
dxtr: lwt 3.1.0, coincidentally :)
jlam_ has quit [Ping timeout: 248 seconds]
<aantron_>
now that we have N forums, i don't which announcement to link. let's try discourse...
<aantron_>
average: yes they are i guess. moved on to?
<average>
aantron_: something more important?
<aantron_>
i assume most people were always working on something more important
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
pierpa has joined #ocaml
jlam_ has joined #ocaml
jlam__ has quit [Ping timeout: 268 seconds]
jlam__ has joined #ocaml
jlam_ has quit [Ping timeout: 240 seconds]
<dxtr>
heh
<aantron_>
alright
<aantron_>
dxtr: lines 3, 4 in markov_db.ml can be replaced by open Lwt.Infix
<dxtr>
Oh cool
<dxtr>
I think want I basically would like is some pointers in how I should structure this. I can't come up with a neat way that won't force me to either make a "brain Lwt.t" or a bunch of _ Lwt.t in my brain record
<dxtr>
So I suspect I'm thinking about this wrong
<aantron_>
hmm this is using camlp4 (e.g. try_lwt). the camlp4 syntax is deprecated, it should be replaced by the PPX syntax if possible. see the table here for a summary https://ocsigen.org/lwt/manual/ (search for correspondence table). it was just updated from camlp4 to ppx finally by bobby priambodo yesterday :)
<aantron_>
still taking a look..
<dxtr>
I suspect I'm doing all kinds of wrong here
<dxtr>
:D
enterprisey has quit [Remote host closed the connection]
<aantron_>
ok i see brain.. since there are lots of functions, can you pick one from the set that is causing problems, for us to focus on?
<dxtr>
I think if we solve that then the rest will sort itself out
<aantron_>
is it that it returns a brain Lwt.t?
<dxtr>
Yeah exactly
<dxtr>
That doesn't feel very.. Neat
<aantron_>
i think this is normal
<dxtr>
Considering that will force close to everything to start with Lwt.bind
malina has joined #ocaml
<dxtr>
Is it?
<aantron_>
it means "it will provide a brain (:D) after some waiting on I/O"
<aantron_>
since it takes some I/O to compute the initial state, you would expect your init function to return an 'a Lwt.t
<dxtr>
Oh okay
<aantron_>
the goal after this is to decide what operations you can do without I/O ("pure"), and write those as separate functions that are blind to Lwt, that just take a brain as argument
<aantron_>
the ones that will do further I/O to compute something from brain, for example the next state of brain, take a brain, and produce a brain Lwt.t, or something else in Lwt.t
<dxtr>
So does that mean my stuff in markov_db.ml looks right too? My idea was sort of to break out all Lwt stuff from that and leave it to the caller, but that felt quite dirty too
<aantron_>
(will answer that in a second after taking a look, first:) Markov.to_edges looks like a good example of a pure function you have already written
sz0 has quit [Quit: Connection closed for inactivity]
<aantron_>
i don't immediately see anything bad with markov_db.ml, perhaps you can point me to a place that feels especially wrong :)
<dxtr>
All get_* functions
<dxtr>
Well, basically every function in there
<dxtr>
I didn't have any specific function in mind
<aantron_>
and yes the idea usually is that you factor out as much non-I/O stuff out into some code, and then string those together using lwt in the caller, but the caller here would be another group of functions written by you
<dxtr>
Yeah
<aantron_>
you could also go farther and ask the user of your functions to decide whether to use lwt or not, but that can be involved. e.g. cohttp used functors for this, and i used cps in markup.ml
<dxtr>
Right
<aantron_>
in both cases you still end up with a type taint though, its jjust a matter of not committing to that type taint being instantiated as Lwt.t
<aantron_>
because you are still modeling asynchronous operation (waiting)
<dxtr>
Yeah
<aantron_>
the get functions look fine in isolation
<dxtr>
Yeah I only have them in isolation so far. Haven't come so far as to create the caller yet :)
<dxtr>
Yeah I did that last evening. "OMG IT'S ALMOST COMPILING! Quick, get rid of the last things"
<aantron_>
:D
<dxtr>
2 am coding is the best
<aantron_>
yes i figured some hurrying was involved there, because the rest of the code looks considerably more intelligent than that :p
<dxtr>
Haha
<octachron>
aantron_, now I am wondering if there is a monad tutorial somewhere in the wild based on an "original sin/paradise lost" analogy
<aantron_>
octachron: that sounds like a fun analogy, but im not sure what you mean exactly by it. in any case, i havent heard of one
<dxtr>
aantron_: By the way, to you have an opinion on pgocaml?
<aantron_>
i'm sure there is a large amount of haskell tutorials to look through, maybe they have one
<aantron_>
dxtr: i haven't really used it. but hearsay suggests that it is quite well-regarded
<dxtr>
Right
<dxtr>
I found an interesting quirk yesterday
<dxtr>
People told me to NOT do module PGOCaml = Lwt_PGOCaml
<dxtr>
And I can definitely agree
<dxtr>
But I removed that line and all hell broke lose
<dxtr>
loose even
<dxtr>
I think PGSQL is blindly using PGOCaml
<dxtr>
Not knowing what camlp4 is capable of I guess that makes sense
<aantron_>
is pgocaml using camlp4?
<dxtr>
yes
<octachron>
aantron_, mostly reacting to your type taint terminology: once tainted by the sin (inside a monad), there is no escaping
<aantron_>
:D
<dxtr>
I saw an issue on their github page about converting to ppx
KeyJoo has joined #ocaml
<aantron_>
dxtr: i can't really help with that camlp4 syntax. just promise that the lwt one isn't doing anything crazy. also since pgocaml uses camlp4, it's likely you will want to keep using the lwt camlp4 syntax
<aantron_>
(which you may already know)
<aantron_>
so scratch my comment about the lwt ppx
<aantron_>
octachron: i would be surprised if there wasnt one. google time..
<dxtr>
Yeah, I started using the camlp4 syntax because of one of those files I linked on github earlier
<dxtr>
And I continued using it because pgocaml
<dxtr>
I didn't want to open another can of worms right now
sam____ has joined #ocaml
<aantron_>
apparently haskell has a monad called Tainted..
<dxtr>
I feel like the amount of stuff I'm reading about is growing exponentially as I'm going
<dxtr>
Started with me buying Real World Ocaml a while ago
<aantron_>
dxtr: last i looked (this was a year or more ago) camlp4 actually cant parse ppx, so you cant mix them in the same source file, and manually telling your build system which files to preprocess with ppx and which with camlp4 is annoying, so sticking with camlp4 is a good choice i think
<dxtr>
That's what I assumed
<aantron_>
i found some haskell monad tutorials mentioning the word taint, but they mention the word taint pretty late, and one of them starts with a slighty intimidating paragraph if you're not already doing haskell
<octachron>
aantron_, camlp4 is mostly in maintenance mode, I don't think that there any plan to make it support attributes and extension nodes
<dxtr>
Wait are you talking to me about the monad stuff?
<octachron>
aantron_, well I found a canadian art troup called Monad performing a Paradise Lost performance, I am nearly surprised that this was not a metal band
<aantron_>
"No Action is Not an Option" <-- FP triggered
<octachron>
it could be a group action
ryanartecona has quit [Quit: ryanartecona]
<dxtr>
Also, should I ditch oasis for jbuilder?
Soni has quit [Ping timeout: 240 seconds]
<dxtr>
I'm trying to follow current "best practices" if there are any
<aantron_>
dxtr: it depends on your needs, but probably yes
<aantron_>
dxtr: we actually found jbuilder doesnt quite support everything needed for lwt, without resorting to generating jbuild files, for example, but it should work for most projects, and hopefully it will improve over time
<dxtr>
Right
<dxtr>
Oh yeah, aantron_. One thing I got stuck on yesterday
<dxtr>
Markov.learn_tokens
<dxtr>
Didn't quite get how I would Lwt-ify that one
<dxtr>
Specifically the variables pid and next_id
jlam_ has joined #ocaml
<aantron_>
looking..
jlam__ has quit [Ping timeout: 240 seconds]
<dxtr>
Actually I guess the whole function
<aantron_>
first, why do you want to Lwt-ify it?
<dxtr>
Because get_node_by_tokens return int32 Lwt.t
<aantron_>
ah
<aantron_>
yeah just saw it
jlam_ has quit [Ping timeout: 240 seconds]
<aantron_>
you want next_id to not be an _ Lwt.t, but it is, right?
<aantron_>
for pid, you would do lwt pid = match prev_id with | None -> (* what you have *) | Some p -> Lwt.return p in
<aantron_>
obviously with the newlines as you have them now.. :)
<aantron_>
the lwt keyword is the lwt camlp4 syntax abbreviation for Lwt.bind, but it looks like let
<aantron_>
for next_id you should be able to just change the let keyword to lwt
<dxtr>
Oh
<aantron_>
it looks like those two calls might not have a dependency that requires you to sequence them
<aantron_>
(but maybe they still share state internally that requires sequencing anyway, i don't know what they do)
jlam__ has joined #ocaml
<aantron_>
actually they probably do. but if they didn't, you could create two promises (Lwt.t) using ordinary let
<aantron_>
that would trigger their resolution in parallel
<dxtr>
Right
<aantron_>
and then to get both values outside Lwt.t, you would do lwt pid = pid_promise in lwt next_id = next_id_promise in (* the rest of the code that needs both *)
jlam1 has joined #ocaml
Soni has joined #ocaml
<dxtr>
pid can run in parallel with the rest but new_edge is depending on next_id
<aantron_>
which of course just forces the code to wait for both before continuing.
Simn has quit [Quit: Leaving]
jlam_ has quit [Ping timeout: 255 seconds]
<aantron_>
well it looks like new_edge depends on both pid and next_id, so maybe only pid and next_id can run in parallel
<dxtr>
Oh yeah sorry
jlam1 has quit [Read error: Connection reset by peer]
jlam__ has quit [Read error: Connection reset by peer]
<aantron_>
the code i see does run them in parallel though
<aantron_>
because of the ordinary lets
jlam_ has joined #ocaml
<aantron_>
those calls get_node_by_tokens spawn computations and return promises immediately
<aantron_>
actually im not even sure how this works, still reading code
<dxtr>
Haha
jlam_ has quit [Read error: Connection reset by peer]
jlam_ has joined #ocaml
<dxtr>
Yeah the reduce function is a little hairy
infinity0 has quit [Ping timeout: 258 seconds]
<aantron_>
does this compile? it looks like your add_edge expects regular values, but you are passing promises to it
<aantron_>
or i am missing something
<dxtr>
No it does not
<aantron_>
ok :p
<dxtr>
Which is why I got stuck on it yesterday :)
infinity0 has joined #ocaml
_andre has quit [Quit: leaving]
<aantron_>
so to summarize, basically, for the simple version you do "lwt pid = ... in lwt next_id = ... in add_edge ..." - this is sequential. for parallel, you do "let pid_promise = ... in let next_id_promise = ... in lwt pid = pid_promise in lwt next_id = next_id_promise in add_edge ..."
<dxtr>
Yeah
<dxtr>
Can I recurse like this in a bind?
jlam_ has quit [Read error: No route to host]
jlam__ has joined #ocaml
jlam__ has quit [Read error: Connection reset by peer]
jlam_ has joined #ocaml
<aantron_>
yep, your functions just have to return promises
<dxtr>
Right
<aantron_>
(or you could use map, but iirc the camlp4 syntax doesn't help with map as much as it does with bind)
MK__ has joined #ocaml
<MK__>
is there any opam switch to install async extension of a library?
dakk has quit [Quit: Leaving]
<dxtr>
aantron_: Lwt_list could be more documented :)
<dxtr>
Also, will any of my code in Markov_db actually run concurrently?
enterprisey has quit [Remote host closed the connection]
aciniglio has quit [Ping timeout: 246 seconds]
<MK__>
In a project library, there is a module under async library. How can I use the functions under async dir for the library? Is that Library_async.function ?
<MK__>
async library -> async folder
argent_smith has quit [Quit: Leaving.]
ryanartecona has quit [Quit: ryanartecona]
__marioxcc has joined #ocaml
__marioxcc has left #ocaml [#ocaml]
argent_smith has joined #ocaml
Orion3k has joined #ocaml
<dxtr>
aantron_: It compiles now!
<dxtr>
Woop woop
<dxtr>
Check it out
cranmax has joined #ocaml
argent_smith has quit [Quit: Leaving.]
sam____ has quit [Ping timeout: 240 seconds]
dreadedfrog has quit [Ping timeout: 255 seconds]
MK__ has quit [Remote host closed the connection]
jlam_ has quit [Read error: Connection reset by peer]
jlam_ has joined #ocaml
ryanartecona has joined #ocaml
aantron_ has quit [Remote host closed the connection]