nicholasf has quit [Remote host closed the connection]
nicholasf has joined #ocaml
Reshi has joined #ocaml
sz0 has joined #ocaml
<seliopou>
Yo what's up did you guys figure out the aws stuff?
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
oxcsh has quit [Remote host closed the connection]
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
Reshi has quit [Ping timeout: 260 seconds]
yunxing has quit [Remote host closed the connection]
<Drup>
seliopou: the meta claims it needs only cohttp.lwt-core while it seems to need cohttp.lwt
<Drup>
or something like that
therac25 has joined #ocaml
oxcsh has joined #ocaml
silver has quit [Read error: Connection reset by peer]
jeffmo has joined #ocaml
pyon has joined #ocaml
julien_t has quit [Ping timeout: 264 seconds]
zRecursive has joined #ocaml
groovy2shoes has quit [Quit: Leaving]
FreeBirdLjj has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
nicholasf has quit [Remote host closed the connection]
yunxing has joined #ocaml
nicholasf has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
yunxing has quit [Remote host closed the connection]
sh0t has quit [Ping timeout: 268 seconds]
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
zRecursive has left #ocaml ["ERC (IRC client for Emacs 24.5.1)"]
nuuit has quit [Ping timeout: 260 seconds]
henrytill has quit [Ping timeout: 260 seconds]
nuuit2 has joined #ocaml
henrytill_ has joined #ocaml
michael_lee has joined #ocaml
sh0t has joined #ocaml
sh0t has quit [Ping timeout: 268 seconds]
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
oxcsh has quit [Remote host closed the connection]
oxcsh has joined #ocaml
sh0t has joined #ocaml
henrytill_ is now known as henrytill
henrytill has quit [Changing host]
henrytill has joined #ocaml
therac25 has quit [Remote host closed the connection]
FreeBird_ has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 276 seconds]
seangrove has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
therac25 has joined #ocaml
govg has quit [Ping timeout: 244 seconds]
therac25 has quit [Client Quit]
sh0t has quit [Ping timeout: 240 seconds]
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
kdas__ is now known as kushal
kushal has quit [Changing host]
kushal has joined #ocaml
keep_learning has joined #ocaml
<seliopou>
Drup you are very right
struk|desk is now known as struk|desk|away
jeffmo has quit [Quit: jeffmo]
Sorella has quit [Quit: Connection closed for inactivity]
seangrove has quit [Ping timeout: 260 seconds]
nicholasf has quit [Ping timeout: 244 seconds]
pierpa` has joined #ocaml
pyon has quit [Ping timeout: 240 seconds]
sgnb`` has quit [Ping timeout: 240 seconds]
smondet has quit [Ping timeout: 268 seconds]
smondet has joined #ocaml
pyon has joined #ocaml
struk|desk|away is now known as struk|desk
pierpa has quit [Ping timeout: 240 seconds]
seangrove has joined #ocaml
sz0 has quit [Ping timeout: 240 seconds]
keep_learning has quit [Ping timeout: 240 seconds]
d0nn1e has quit [*.net *.split]
strmpnk has quit [*.net *.split]
phrst has quit [*.net *.split]
keep_learning has joined #ocaml
AlexRussia has quit [Ping timeout: 260 seconds]
d0nn1e has joined #ocaml
phrst has joined #ocaml
strmpnk has joined #ocaml
tennix has joined #ocaml
<tennix>
Is OCaml generics static dispatch or dynamic dispatch?
<def`>
what???
<tennix>
C++ or Rust generics are static dispatch, compilers will replace generics invokation with exact function at compile time
<tennix>
thus generics have no runtime overhead
<def`>
what do you mean by generics?
<tennix>
foo<T>()
<def`>
Because there is nothing like templates in OCaml.
ggole has joined #ocaml
<tennix>
let f a b = if a < b then a else b
<def`>
Polymorphic comparison works by introspection of runtime values, so there is only one funciton.
<def`>
function*.
<asdf12z_>
silly question... in a function composition what would be the correct term for the first (a), 'middle' (b), and last (c) functions? c(b(a(x))) if there is none, what would be something appropriate? i was just thinking of referring to head, spread, and tail...
<def`>
If you ask about data structure representation: OCaml has a uniform representation that is never specialized.
<def`>
If you ask about dispatch: there is no dynamic dispatch in OCaml except for classes.
<tennix>
So OCaml doesn't have generics like C++/Rust
<def`>
No.
<def`>
If you ask about ad-hoc polymorphism: modular implicits is the proposed extension and is being worked on. dispatch will be static.
<tennix>
So that's why there's print_int, print_float, print_string
<def`>
That's because the lack of ad-hoc polymorphism yes.
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
<tennix>
Ok, that question confused me when i first look at OCaml. Since OCaml is a powerful language I think it definitely support C++/Rust like generics
<def`>
Mainstream programming language terminology is so informal that terms have no meaning. C++ generics are C++ generics, Rush generics are Rust generics.
<def`>
However if we look at specific features, then OCaml has strongly emphasize parametric polymorphism.
<def`>
-has.
<def`>
C++ and Rust doesn't have this one, although it can be encoded.
<def`>
However OCaml has nothing like ad-hoc polymorphism, that is changing the semantics according to types.
<def`>
That's what you would like it seems, but sorry, not yet.
<def`>
This is not without reason, it is hard to define while keeping maintaining some good properties of the language.
<def`>
It should come at some point though.
<tennix>
that way for efficiency programmers have to define similar functions for different types with different names(usually type as suffix)
<def`>
Ok... I should stop writing, it's full of typos :P
<def`>
depends what you are trying to solve, your solutions works only for first-order code. Most OCaml code is more generic than that.
seangrove has quit [Ping timeout: 276 seconds]
Emmanuel` has quit [Quit: Konversation terminated!]
<flux>
at some point I think I'll extract the bindings to a separate project
d0nn1e has quit [*.net *.split]
strmpnk has quit [*.net *.split]
phrst has quit [*.net *.split]
Emmanuel` has quit [Client Quit]
<def`>
good
<flux>
there's actually ffmpeg bindings in opam, but as far as I can see, it provides only scaling. and license information :)
<flux>
(ffmpeg license can depend on compiling options)
<flux>
but this of course means I need to call my project something else than (ocaml-)FFmpeg. maybe FFmpeg3 :)
d0nn1e has joined #ocaml
destrius has quit [Quit: leaving]
Emmanuel` has joined #ocaml
<therac25>
Can anybody point me to an example of a program using cohttp, that is functorized over Lwt or Async ? I am trying to functorize the following code: http://lpaste.net/154463 but I am getting stuck when it comes to the Client module (in Client.get ()). An example would be neat…
destrius has joined #ocaml
strmpnk has joined #ocaml
phrst has joined #ocaml
larhat has quit [Quit: Leaving.]
lobo has joined #ocaml
oxcsh has quit [Remote host closed the connection]
Reshi has joined #ocaml
orbifx has quit [Ping timeout: 276 seconds]
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
oxcsh has joined #ocaml
rishi has joined #ocaml
rishi is now known as Guest3459
Reshi has quit [Ping timeout: 244 seconds]
ggole_ has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
oxcsh has quit [Remote host closed the connection]
Guest3459 has quit [Quit: WeeChat 1.4]
Reshi has joined #ocaml
yunxing has quit [Remote host closed the connection]
octachron has joined #ocaml
yunxing has joined #ocaml
yunxing_ has joined #ocaml
michael_lee has quit [Remote host closed the connection]
michael_lee has joined #ocaml
yunxing has quit [Ping timeout: 248 seconds]
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
seangrove has joined #ocaml
rishi has joined #ocaml
rishi is now known as Guest76983
Guest76983 has quit [Client Quit]
Reshi has quit [Ping timeout: 240 seconds]
therac25 has quit [Quit: therac25]
seangrove has quit [Ping timeout: 246 seconds]
Anarchos has joined #ocaml
Haudegen has quit [Ping timeout: 264 seconds]
ygrek has quit [Ping timeout: 264 seconds]
Kakadu has joined #ocaml
avsm has joined #ocaml
cdidd has joined #ocaml
cdidd_ has quit [Ping timeout: 260 seconds]
infinity0 has quit [Ping timeout: 276 seconds]
infinity0 has joined #ocaml
Haudegen has joined #ocaml
warp has joined #ocaml
oxcsh has joined #ocaml
silver has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
oxcsh has quit [Ping timeout: 248 seconds]
avsm has quit [Quit: Leaving.]
ggole has quit []
ggole_ is now known as ggole
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
jwatzman|work has joined #ocaml
yunxing_ has quit [Remote host closed the connection]
avsm has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
seangrove has joined #ocaml
mort___ has joined #ocaml
seangrove has quit [Ping timeout: 240 seconds]
mettekou has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
badon has quit [Ping timeout: 246 seconds]
kushal has quit [Quit: Leaving]
orbifx has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
avsm has quit [Quit: Leaving.]
sepp2k has joined #ocaml
darkf has quit [Quit: Leaving]
badon has joined #ocaml
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
AlexRussia has joined #ocaml
badon has quit [Disconnected by services]
badon_ has joined #ocaml
yunxing has joined #ocaml
<orbifx>
Is there a way to group fields of same time in Cstruct or even ocaml in general?
Emmanuel` has quit [Quit: Konversation terminated!]
Emmanuel` has joined #ocaml
mettekou has quit [Ping timeout: 244 seconds]
TheLemonMan has joined #ocaml
AlexRussia has quit [Ping timeout: 252 seconds]
xardon has quit [Remote host closed the connection]
_andre has joined #ocaml
<tennix>
what's the current status of modular implicits?
<companion_cube>
still WIP afaik
mort___ has quit [Quit: Leaving.]
pierpa` has quit [Ping timeout: 244 seconds]
Emmanuel` has quit [Ping timeout: 260 seconds]
<mrvn>
Are there debian packages for 4.03 somewhere already?
Ruff has quit [Ping timeout: 248 seconds]
mort___ has joined #ocaml
badon__ has joined #ocaml
badon__ is now known as badon
badon_ has quit [Ping timeout: 240 seconds]
<tennix>
probably not, since archlinux hasn't got 4.03 in official repo, debian is much more conservative
sillyotter has joined #ocaml
<Drup>
Guys, 4.03 is not even released yet ...
sillyotter has quit [Client Quit]
Reshi has joined #ocaml
<mrvn>
Drup: no reason that someone wouldn't have build pre-release debs
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
tennix has quit [Ping timeout: 260 seconds]
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
sillyotter has joined #ocaml
kushal has joined #ocaml
sillyotter has quit [Client Quit]
seangrove has joined #ocaml
seangrove has quit [Ping timeout: 240 seconds]
tennix has joined #ocaml
nicoo has quit [Ping timeout: 260 seconds]
nicoo has joined #ocaml
<Kakadu>
Well, I'm trying to write down my thought about heterogenous map. https://gist.github.com/Kakadu/8e39cd1e2fb936cf90ec I would like to know about any other approaches to prevent looking for some keys in some maps (except generative functors approach which was mentioned yesterday)
tennix has quit [Ping timeout: 276 seconds]
kushal has quit [Ping timeout: 244 seconds]
<mrvn>
Kakadu: I've got a solution for events now. I'm keeping a Weak.t reference to the ocaml class and can check if it has an event() method and call it.
<octachron>
Kakadu, first, it is worrying that your heterogeneous map implementation can segfault
<ggole>
Kakadu: are you trying to implement a type preserving map?
kushal has joined #ocaml
<ggole>
eg, a map from 'a key -> 'a value for all 'a?
<Kakadu>
well, maybe it should be called type preserving, but I didn't heared this words before
<mrvn>
it's usualy called universal
<ggole>
But you want to use it with GADTs so that lookups in the map allow knowledge of the type parameter?
<mrvn>
Kakadu: why do you have one counter per map? If you use a global counter then "reify key1 m2" will simply raise Not_found.
<Kakadu>
ggole: I dont know what to answer. I'm not really specifically GADTs, good solution without them will be OK. I alsready switched to 4.02.3+implicits som all that stuff will be very welcome
oxcsh has joined #ocaml
<mrvn>
Kakadu: Afaik there are 3 ways to generate keys: Have the user supply a witness type recursively constructed from the type definition (e.g. sexpr library makes them), generate a unique key for every entry, have first class module/functor generate reusable witnesses for types.
<Kakadu>
mrvn: It's weird that I didn't thought about it before. But is seems more workaround than a solution. To archive the same I could use physical equality when looking for key in the map
<mrvn>
not if the key is an int
mort___ has quit [Ping timeout: 268 seconds]
<mrvn>
Kakadu: you can box values in a polymorphic record with the key being a pair of getter/setter function for the record.
<ggole>
fold_broken will not type check because of the monomorphism of f
yegods has joined #ocaml
axiles has quit [Ping timeout: 250 seconds]
<ggole>
Now that I think about it, map would be a bit strange
<ggole>
You could write a map taking every value to one type, or every value to it's own type
larhat has joined #ocaml
<ggole>
But the former would defeat the purpose of using a type preserving map
<ggole>
(Er, map in the data structure sense.)
larhat has quit [Read error: Connection reset by peer]
larhat has joined #ocaml
Reshi has joined #ocaml
<octachron>
ggole, certainly maping all types to a single type destroy informations but it might be useful to forget type information from time to time
<ggole>
octachron: right, but a polymorphic map should be possible... actually I'm halfway through attempting to do it using an existential wrapper to hide the type index of the result
<octachron>
ggole, you could also have f takes a wraped argument, isn'it?
<ggole>
Yeah
<ggole>
At least, I think
<mrvn>
ggole: you can map all values of one type leaving everything else alone. Or you map any type having the map function use the witness key to map each type individually.
mort___ has joined #ocaml
<mrvn>
Kakadu: ever used open types? They can be usefull too
<Kakadu>
no, never
* Kakadu
is thinking how to use that alist.ml....
<mrvn>
You have a open type 'a key and users add their own variants to that type to keep value types straight.
keep_learning has quit [Read error: Connection timed out]
<mrvn>
Not universal but extensible.
<ggole>
You can implement Univ on top of them though
keep_learning has joined #ocaml
AlexRussia has joined #ocaml
AltGr has left #ocaml [#ocaml]
sgnb has joined #ocaml
kushal has quit [Ping timeout: 276 seconds]
struk|desk|away is now known as struk|desk
seangrove has joined #ocaml
kushal has joined #ocaml
seangrove has quit [Ping timeout: 264 seconds]
copy` has joined #ocaml
dhil has joined #ocaml
mort___ has quit [Quit: Leaving.]
keep_learning has quit [Read error: Connection timed out]
<Kakadu>
Okay, it is very stupid question but which other implementations are possible for let eq: 'a key -> 'b key -> ('a,'b) eq = fun a b -> NEq
<Kakadu>
?
<ggole>
Kakadu: you have to provide one, depending on key
<ggole>
(It's a functor argument, remember.)
<ggole>
In short: you choose a key and value type and then provide type-index aware equality for key
<ggole>
I'll add an example if you like.
<Kakadu>
yeah
<Kakadu>
It is just not obvious what to write there
<ggole>
OK.
<Kakadu>
because let eq: 'a key -> 'b key -> ('a,'b) eq = fun a b -> Eq (* doesn' type check *)
<mrvn>
Kakadu: you have to "match (key1, key2) with ..." and cover all the cases.
<ggole>
You also have to use (type t) annotations
<mrvn>
There realy should be a MAGIC eq in ocaml that does a structural comparison without one having to list all the cases.
<companion_cube>
:}
<mrvn>
let eq : type a b . a key -> b key -> (a, b) eq = %eq
<ggole>
I don't think that is sound
<Drup>
I think that this is grossly unsound :3
<ggole>
type 'a key = 'a and then 0 and () are equal
<ggole>
Boom
<ggole>
Sound machinery, perhaps built on ppx_deriving, would indeed be useful.
<Kakadu>
ggole: but this kind of map will be only for finite `kinds` of keys. And to use key with a brand new type I should change the implementation?
<mrvn>
%unsafe_eq
Haudegen has quit [Remote host closed the connection]
<mrvn>
Kakadu: there only is a finite "kinds" of keys. You only have the basic types, records, objects and modules.
<mrvn>
Kakadu: you have to encode records recursively.
<ggole>
Kakadu: well, you have to apply the functor for each pair of key and value type
<mrvn>
ggole: Problem with deriving is that you have to compare all the case. The code grows while for sound types the generic eq works. Combine the deriving with the %unsafe_eq
Reshi has quit [Ping timeout: 246 seconds]
<mrvn>
last time I used Obj.magic and compare.
<companion_cube>
with deriving you could make n+1 branches for a type with n cases
<ggole>
You could write the plugin to use primitives where that works
<Kakadu>
ggole: What I meant that we need to change type _ ty = ... to be able to use, for example, int32 as a key
<mrvn>
companion_cube: taking n comparisons. You only need one there.
keep_learning has quit [Read error: Connection timed out]
malc_ has joined #ocaml
<ggole>
Kakadu: so.. you want an open type but still a type-aware eq?
<ggole>
I think this is possible with some type hacking
<ggole>
But it would be pretty clumsy (the way I'm thinking of doing it)
<Kakadu>
Well, probably
<Kakadu>
a HMap without any restrictions to the keys
<mrvn>
if you have an opten type then Obj.magic them both to unit t and use ==
<Drup>
ಠ_ಠ
<ggole>
What do you mean, no restriction on the keys? No type index?
<ggole>
(If you don't have a type index, this is not an appropriate technique.)
<Kakadu>
ggole: your type _ ty means that we are making HMap where keys are allowed to be strings, ints and floats. I call that a restriction
<Kakadu>
not value restriction, ofcourse
larhat has quit [Quit: Leaving.]
malc_ has left #ocaml ["ERC (IRC client for Emacs 25.0.50.2)"]
<Kakadu>
maybe I need to use another word
Reshi has joined #ocaml
<ggole>
You want polymorphism over the key type? So that the signature of, say, find is val find : 'a 'k -> 'k map -> 'a value option?
<ggole>
OCaml can't do that.
<mrvn>
ggole: it can
<ggole>
(Maybe with higher or similar hacks, but not directly.)
<Kakadu>
because 2 rank polymorphism (or how it is called right?), ggole?
<mrvn>
ggole: directly
<ggole>
Higher kinded types
<ggole>
(Rank-2 polymorphism is possible with record wrappers.)
<Kakadu>
okay, but Haskell doesn't have Higher kinded types too, AFAIR
<mrvn>
type 'a access = { get : 'unit -> 'a; set : 'a -> unit } type key = { access : 'a . 'a access }
<mrvn>
or something like that
<ggole>
Kakadu: it does, it's one of the advantages of Haskell over OCaml
mettekou has joined #ocaml
<mrvn>
can one write an eq for open types without Obj.magic or C stub?
<mrvn>
ggole: ahh, you are creating objects that can compare only true to their own type to box the values.
<mrvn>
ggole: I was thinking that each time you extend the open type you would also have to extend the eq.
<mrvn>
ggole: your eq will have "eq Tag2 Tag2 = false" but that is ok since your use is only interested in "eq Tag ..."
<mrvn>
How hard would you think would it be to add "class foo = object(self:'self) external bla : 'self -> unit = "bla_stub" end?
struk|desk|away is now known as struk|desk
tane has joined #ocaml
<ggole>
To the compiler? No idea.. the object stuff is a bit complicated.
<mrvn>
ggole: I saw
yegods has quit []
yegods has joined #ocaml
mort___ has joined #ocaml
jeffmo has joined #ocaml
<tennix>
I just compared polymorphism between Haskell and OCaml, and found that OCaml prefers to monomorphisize manually while haskell prefers to rely on GHC
<tennix>
so OCaml looks a little ugly, but easy to reason about efficiency
<Drup>
monomorphise manually ?
<tennix>
I'm just a newbie of both language learner
<tennix>
I mean print_string, print_int, print_float
<Drup>
Right, sort of
<Drup>
it's not really monomorphisation
<tennix>
to explicitly specialized
<tennix>
yes, i know that
emias has quit [Ping timeout: 244 seconds]
yegods has quit []
<Drup>
But yes, as def` explained to you last time, it's due to lack of ad-hoc polymorphism
<tennix>
Does ad hoc polymorphism do monomorphism?
yegods has joined #ocaml
<Drup>
monomorphisation is the process of taking a generic function and making it specialized for a type. It's mostly an optimization thing. The kind of genericity doesn't matter.
MercurialAlchemi has quit [Ping timeout: 260 seconds]
larhat has joined #ocaml
yegods has quit []
emias has joined #ocaml
yegods has joined #ocaml
Reshi has quit [Quit: WeeChat 1.4]
hxegon has joined #ocaml
mort___ has left #ocaml [#ocaml]
<Kakadu>
So, does lack of higher kinded types means that I can't define function like val do_something : {X: MONAD} -> person X.t -> purchase X.t -> someting ?
<companion_cube>
currently
<Drup>
Kakadu: you can with implicits :p
* Kakadu
always have had strange feeling that implicits are converting OCaml into Haskell
<companion_cube>
naaaah :D
sh0t has joined #ocaml
<Kakadu>
Drup: are you sure? :)
<Drup>
yes
seangrove has joined #ocaml
struk|desk is now known as struk|desk|away
OnkV has joined #ocaml
<orbifx>
What's the simplest way for two Threads to communicate with one another? Shared memory?
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
yegods_ has joined #ocaml
yegods has quit [Read error: Connection reset by peer]
FreeBird_ has quit [Ping timeout: 264 seconds]
<mrvn>
type t = c -> unit external stub : t = "stub" "Error: External identifiers must be functions" Why doesn't that work?
<orbifx>
Thanks mrvn. That might come in handy when I need to process all values. Does it share a reference when you pass it? Or does it make a copy?
<mrvn>
it's a value. ints are copied, complex stuff is refrenced
<ggole>
orbifx: Threads run within the same process and never interleave, so copying isn't necessary and data races are not a concern
darkf has joined #ocaml
<ggole>
Er, not interleave. Never run at the same time is what I meant.
<mrvn>
except they can switch inbetween any 2 allocations
<mrvn>
(hence the mutex)
<ggole>
Right, so you need Mutex to keep mutations from sneaking in when you don't want them
jwatzman|work has quit [Read error: Connection reset by peer]
jwatzman|work has joined #ocaml
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jgjl has joined #ocaml
ygrek has joined #ocaml
oxcsh has joined #ocaml
slash^ has joined #ocaml
shinnya has quit [Ping timeout: 248 seconds]
oxcsh has quit [Ping timeout: 260 seconds]
<seliopou>
I'm writing a custom formatter to be used in conjunction with kfprintf exclusively. I would like to use calls to flush to flush output to the underlying device. The problem is that the formatter has not necessarily run once passed to the continuation, meaning that a flush has to be introduced in the continuation just to get output. Is there a way to get the formatter to run without introducing a call to flush?
aantron has quit [Remote host closed the connection]
<Drup>
seliopou: I don't understand what you are saying
<seliopou>
Drup :)
<Drup>
by custom formatter, do you mean a thing to use with %a, or a thing of type Format.formatter ?
<seliopou>
latter
<Drup>
Ok.
<seliopou>
thing of type Format.formatter
<Drup>
I still don't understand, but at least the vocabulary is clear
<Drup>
:D
<seliopou>
So if I do `kfprintf k fmt "here's a string%! to print"`, the %! indicates that the output up until then should be flushed
<seliopou>
if I remove that %!, then within k, none of the formatting callbacks have been called yet
<seliopou>
so in order to actually get output, I have to call Format.pp_print_flush fmt
<seliopou>
which is equivalent to "here's a string to print%!"
<seliopou>
the problem is that in my custom formatter, I want %! to correspond to flushing an output stream
<seliopou>
and correspond directly with user intent, i.e., i don't want to introduce flushes that the user did not explicitly ask for
<seliopou>
You feel me?
<orbifx>
ggole: i understand the memory model on that aspect. Whst I don't know is how to best pass values around which are essentially generated by two threads
badon has quit [Disconnected by services]
badon_ has joined #ocaml
badon_ is now known as badon
<Drup>
So you want flushing to be really flushing and you don't want to introduce extra flushes
<Drup>
what is the problem ?
<seliopou>
the problem is that i can't actually get output without introducing a flush
<orbifx>
ggole Both threads are mutual producers and consumers.
<seliopou>
so if the user specifies a format string without a flush, nothing will happen :/
<Drup>
Then you can't respect the second condition.
<seliopou>
no output will be generated
<seliopou>
right but also i don't know the api very well, so i'm wondering if there's a way to do this that i haven't contemplated
<Drup>
I don't know, depends on your formatter
<seliopou>
in what way?
<Drup>
But if the formatter is the same, the content will eventually be flushed in the subsequent calls to kfprintf
<Drup>
the content is not lost, it's just not flushed yet
aantron has joined #ocaml
<Drup>
But it seems to me you are asking for two contradictory things, you want no magically inserted flushing, but you still want magically inserted flushing :D
<Drup>
(well, it's not very magic, but still)
<seliopou>
well kindof but not completely
<Drup>
(18:08:45) seliopou: well kindof but not completely
<Drup>
:D
<seliopou>
:)
<seliopou>
so let's put it this way
<seliopou>
i want the behavior of ksprintf but without the additional buffer allocation
<seliopou>
hmmmm
<seliopou>
yeah ok maybe this doesn't make sense
<seliopou>
%! is flushing the internal formatter buffer
<seliopou>
i want to use it to flush the output stream
<seliopou>
they're not the same, qed.
<Drup>
Well, no, flush is for flushing the formater
<Drup>
If the formatter is an output_stream, it flushes the output_stream, if it's an internal buffer, it does nothing since there is no need to flush
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
jwatzman|work has quit [Quit: jwatzman|work]
larhat has joined #ocaml
seangrove has quit [Ping timeout: 276 seconds]
warp has quit [Ping timeout: 240 seconds]
groovy2shoes has joined #ocaml
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
jeffmo has quit [Quit: jeffmo]
orbifx2 has joined #ocaml
orbifx has quit [Ping timeout: 252 seconds]
mettekou has joined #ocaml
Kakadu has quit [Quit: Page closed]
tennix has quit [Ping timeout: 276 seconds]
yunxing has joined #ocaml
octachron has quit [Quit: Leaving]
keep_learning has joined #ocaml
OnkV has quit [Ping timeout: 244 seconds]
<mrvn>
can someone think of a reason why external must be a function? Why can't it be an abstract type or even ocaml type? In the end it's just a linker symbol with the address.
<mrvn>
type t external get_obj : unit -> t = "get_obj" let obj = get_obj () seems silly.
andreypopp__ has quit [Ping timeout: 276 seconds]
mettekou has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
andreypopp__ has joined #ocaml
ygrek has quit [Ping timeout: 240 seconds]
mettekou has joined #ocaml
Haudegen has joined #ocaml
tennix has joined #ocaml
<infinity0>
is there an ocaml async event/callbacks library that supports single-producer multiple-consumers?
<infinity0>
oh wait ignore that, i can probably use some combination of lwt / lwt_stream
<j0sh>
infinity0: depends on what you want the 'multiple consumers' semantics to be... lwt_stream might work
<infinity0>
i'm looking for something with similar semantics to eventemitter in javascript, where the producer produces a stream, but consumers can attach/detach themselves from the stream dynamically
<j0sh>
i think thats doable with Lwt_stream right now, but you'll probably have to be careful detaching from streams, especially if you're not going to kill the consuming Lwt thread
<j0sh>
otherwise messages could just queue up forever.
<companion_cube>
yeah, streams in Lwt are hard to predict
<companion_cube>
I have some blocking queue for Lwt somewhere on github, but it's not released
julien_t has joined #ocaml
<infinity0>
hmm, yeah for the semantics i'm thinking of, when a consumer detaches they just don't get those items
<infinity0>
i guess this in general makes the overall behaviour "hard to predict", is there some philosophical discouragement of that from the FP developer community and if so what are the suggested alternatives?
<infinity0>
i mean it's not super hard to predict, just makes it more impure and less easy to prove things about, i guess... i'm fine with it, but wondered if it would be "not the ocaml way" or something
ygrek has joined #ocaml
<j0sh>
infinity0: if you read the github thread, the semantics of Lwt_stream were intentionally left a bit vague to simplify the implementation. Nothing philosophical, mostly "this works in most circumstances, good enough for now," although that specific multi-consumer behavior probably should have been documented
<infinity0>
ah, ok, i guess this is generally unexplored territory ok
<infinity0>
also it looks like the multiple consumers all "consume" the item so that no other consumers also get it, which is not what i was looking for (and perhaps i should have picked a better word than "consumer")
<infinity0>
fuck it i guess it's time to roll my own lol
<mrvn>
YOu want to broacast to all "consumers"?
<j0sh>
what I usually do is have a stream per consumer and push to each of them sequentially
Kakadu has joined #ocaml
<infinity0>
what i'm doing is more like "events/observables" so each observer should see each event (that occurs after they attached and before they detached)
<infinity0>
and the publisher doesn't need to directly know who is observing, i.e. a separation of concerns
<j0sh>
arr, messed up the copy and paste. fixed in the gist.
<infinity0>
j0sh: ah thanks, yeah there's some differences but i can work in its ideas
<infinity0>
someone suggested maybe i should work towards having something suitable for Lwt_pubsub or Lwt_event, in which case it should cover as general semantics as reasonable
<infinity0>
the thing i specifically want i had previously already implemented it in js and python, so it should be fairly easy to translate into ocaml..
mettekou has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
julien_t has quit [Ping timeout: 248 seconds]
* mrvn
fights with QT5 over ownership of widgets
<mrvn>
mine, Mine, MINE
jgjl has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<mrvn>
tennix: well, he had but now it's gone.
<mrvn>
ups, ewin
shinnya has joined #ocaml
<seliopou>
Drup: so imagine that instead of directly manipulating output streams, you're building a representation of write commands that you want to run at a later time
<seliopou>
and you're just using format strings as a edsl for that representation
<seliopou>
then the notions of flusing are not compatible
<seliopou>
;)
<Drup>
But, hum, isn't a format already a representation of write commands ?
<Drup>
Can I look at the actual definition of your formatter ?
<Drup>
You need a tiny bit of comments with that :)
<Drup>
documentation comments*
<Drup>
Proposition "Flushes the internal formatting queue, ensuring that all the printing actions are executed. Will close all boxes and reset the state of the formatter. This will not flush the output. In most cases, the user may want to use {!pp_print_flush} instead."
<seliopou>
Ok I'll add that
<Drup>
Please fix the english too :D
pela has joined #ocaml
<malc_>
Drup: what's wrong with English in that snippet?