<rgrinberg>
@Anurag is there a way to flush more granularly with faraday? E.g. I want to a receive a notification when a particular buffer has been written.
<rgrinberg>
I don't necessarily even want to request the flush
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<d_bot>
<Anurag> Hmm, I don’t think there is a way to track this. I believe faraday only tracks the total count of bytes that make their way through faraday, and just uses that information to wake up any registered callbacks via the flush function.
<d_bot>
<Anurag> But the flush api should give you what you want though. If you register a callback as soon as you schedule your bigstring within faraday, whenever that callback is called you can be sure your buffer has been processed.
wingsorc has joined #ocaml
<d_bot>
<rgrinberg> I assumed it was possible. Just add a callback to the flush queue without triggering a flush. The byte count should be just be current + size of buffer
<d_bot>
<rgrinberg> I could be misunderstanding the api though
Guest64873 has joined #ocaml
Guest64873 has left #ocaml [#ocaml]
<d_bot>
<Anurag> Hmm, maybe the terminology is a little confusing here, I believe in faraday when you call the flush function the only action happening is the registering of the user provided callback. The faraday buffer's content will be available to write whenever you call `Faraday.operation` , but that's the same even if you don't call `flush` and just use say `write_string`, `write_char` etc
spip has joined #ocaml
spip is now known as Guest2263
Guest4325 has quit [Ping timeout: 260 seconds]
<d_bot>
<rgrinberg> @Anurag i think flush is schedule + register callback
rgrinberg has joined #ocaml
<d_bot>
<Anurag> True! I guess the reason why I didn't notice a difference with `write_string` etc was because of `Faraday.operation` which internally calls flush_buffer as well which scheduled the internal buffer to surface as a response for the `operation` function.
<d_bot>
<Anurag> But in the context of a library like faraday i think that's the behavior i'd expect. What would be a need to register a callback via flush, but not have the data surface for a potential write operation via Faraday.operation? 🤔 (Note that if that is indeed needed you can call `yield` after scheduling something and the next `operation` call won't surface anything)
<hackinghorn>
is there a difference between using fileutils and Sys. to run commands?
<rgrinberg>
hackinghorn why do you need fileutils?
<hackinghorn>
rgrinberg, I need to run a few things like cd, ls..
<rgrinberg>
There's Sys.chdir for cd. For ls, there's Unix.opendir
<rgrinberg>
or even Sys.readdir
<hackinghorn>
its not as convenient, I think
<rgrinberg>
@Anurag a concrete example would be batching RPC calls. I'd want a flush notification whenever an RPC request has been written, but I don't necessarily want a separate buffer for every request.
<hackinghorn>
rgrinberg, so you're suggesting not using fileutils?
<rgrinberg>
hackinghorn if you're learning the language, I'd suggest to learn how to do things with the Stdlib. You don't need to always use it, but it's valuable knoweledge
<rgrinberg>
at the very least, it will help in reading other people's code
<hackinghorn>
rgrinberg, I started using it for a 'which' and thought I might do it for everything. is there an alternative to `which`?
<rgrinberg>
I don't think so. I suppose there's always Sys.command "which foo". Or you can re-implement which in a few lines.
<rgrinberg>
Sys.getenv "PATH" |> String.split ':' |> (* etc. *)
<rgrinberg>
Anyway, feel free to keep using it. I have nothing against the library - I've never used it
<rgrinberg>
It doesn't seem very popular, so I doubt many people could help you with it
<hackinghorn>
ahh, I see, thanks
<d_bot>
<Anurag> rgrinberg: You wouldn't have separate buffers though? Your faraday instance will ideally be long lived, and you can serialize multiple requests into it before you attempt to collect the data from faraday to write to the socket/file_system etc
<rgrinberg>
Yup, but I will not have per request flush notifications.
<rgrinberg>
Actually, I'm not sure if Faraday's "flush" is meaningful enough anyway. All it means is that it's ready for the writer
<d_bot>
<Anurag> That is true. At-least not without some careful orchestration of Faraday.write/Faraday.flush. You could choose to only write new content into the faraday buffer from within your flush callback so you can be sure that you only schedule new bytes once the current request has made it all the way through from faraday to your sink.
<d_bot>
<darrenldl> hackinghorn: fileutils has been fine in my use so far
vb has quit [Ping timeout: 240 seconds]
Haudegen has joined #ocaml
vb has joined #ocaml
<hackinghorn>
ahh thankss
shawnw has quit [Ping timeout: 260 seconds]
zebrag has quit [Quit: Konversation terminated!]
mbuf has joined #ocaml
gravicappa has joined #ocaml
<hackinghorn>
is In_channel.read_all good to use?
Colt has quit [Quit: Leaving]
jlrnick has joined #ocaml
shawnw has joined #ocaml
<d_bot>
<darrenldl> is that in core?
<d_bot>
<darrenldl> in any case, depends on what you're doing - fine for small files, better not if the files might be very big
jlrnick has quit [Remote host closed the connection]
<d_bot>
<darrenldl> writes the output to a temp file and move it back, which is similar to how tools would usually work
jlrnick has quit [Read error: Connection reset by peer]
jlrnick has joined #ocaml
Anarchos has joined #ocaml
gravicappa has quit [Ping timeout: 256 seconds]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shawnw has quit [Remote host closed the connection]
shawnw has joined #ocaml
Guest8 has joined #ocaml
<Guest8>
is there a way to get the compiler to expand on "syntax error" ?
<d_bot>
<antron> Syntax error only should be rare, often caused by bad ppx
<d_bot>
<antron> Better ask a specific question about it, if it's a gap in the compiler we might be able to get it patched
Franciman has left #ocaml [WeeChat 3.3]
olle has joined #ocaml
olle has quit [Ping timeout: 250 seconds]
bartholin has joined #ocaml
mbuf has quit [Ping timeout: 250 seconds]
mbuf has joined #ocaml
mbuf has quit [Ping timeout: 256 seconds]
mbuf has joined #ocaml
hannes has joined #ocaml
kakadu has joined #ocaml
gravicappa has joined #ocaml
olle has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
SdeSousa has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Ping timeout: 265 seconds]
xiongxin has joined #ocaml
Haudegen has joined #ocaml
<aru>
I'm pretty new and coming from ruby where there are conveniences for almost anything, ocaml feels a bit lacking in this regard. Guess that's the reason why things like core and batteries exist. What's the general consensus around this?
<d_bot>
<darrenldl> example of conveniences?
<d_bot>
<darrenldl> use of the alternative stdlibs are common, but no consensus on a single go to one afaict
<dmbaturin>
The maintainers are also much less reluctant to extend the standard library now than they used to be.
<aru>
things like List.take_while from core for example
<aru>
I mean it is not difficult to reimplement it myself or anything
<dmbaturin>
If you just want a bunch of convenience functions without replacing the standard library, Containers is a good option.
<aru>
I'll take a look, thanks
<dmbaturin>
If you like Core, nothing wrong with it, but it replaces literally every stdlib function with one of a different type. One may agree or disagree with its design, but it does mean that people will have to know the Core way to contribute to your project.
waleee has joined #ocaml
jlrnick has quit [Ping timeout: 260 seconds]
<d_bot>
<Gooby> When approximately do you think finished typed effects can be expected? I saw someone write next year around April but I am not sure if that's accurate. I just installed the current multicore from https://github.com/ocaml-multicore/multicore-opam#install-multicore-ocaml, and while it's cool what there is now, I can see that there is much more to be added.
<companion_cube>
that seems very dubious yeah
<companion_cube>
it'll probably take years, from my uninformed perspective
<d_bot>
<Gooby> 😳
<sadiq>
there's no hard timeline at the moment, there's some open research going on right now
<sadiq>
(it's just not drifting though, there's resources going in to making it happen)
<d_bot>
<Gooby> Well I'll welcome it whenever it comes
<sadiq>
just to clarify though, you specifically mean typed effects and not effects in general (using the function syntax)?
<d_bot>
<Gooby> Yeah, as far as I see so far just effects using the function syntax are already there in what I linked
<sadiq>
yes, they are good to go and will be there in 5.0
<d_bot>
<Gooby> On the OCaml page I saw that typed effects were planned for multicore, so while I did not think they'd be there in 5.0, I thought "woah maybe they are going to be there soon," but I guess it is a bit of a less researched subject
<sadiq>
it's also something you really want to get right
<dmbaturin>
So far it seems like 5.0 will have a multicore runtime and domains, but effects may be left fo later.
<sadiq>
no, 5.0 will have effects they just won't have syntax for them.
<dmbaturin>
Ah, sorry, I misremembered it indeed.
<sadiq>
the original plan was just multicore runtime and domains.
<d_bot>
<Gooby> Yes it would be very nice to have them
<sadiq>
but there was a lot of momentum behind effects and it seemed like there was concensus for merging both domains and effects for 5.0.
<companion_cube>
will typed effects push the release number to 6.0? :)
<d_bot>
<Kakadu> They will be in 6.0 unless we help somehow 🙂
<d_bot>
<Gooby> To be perfectly honest, even what is currently there is decent for lots of problems such as asynchronous programming, but when reading about typed effects I became very interested in the subject, so I am looking forward to them
<sadiq>
even without syntactic support it's still pretty good
<d_bot>
<Gooby> Especially as it provides a direct alternative to, for example, Haskell's monadic way of encoding of effects
<sadiq>
note that it's the handler that it has the worst impact on
<sadiq>
(which is hopefully the kind of thing that you have in libraries)
<d_bot>
<Gooby> Impact as in the amount of code you have to write?
<sadiq>
basically yea
<d_bot>
<Gooby> Well while that's true, I don't think there's escaping it. As you said, libraries can do it so that the users don't have to, and I don't think other methods of typing effects are much better either
<sadiq>
also it's the kind of thing you could maybe make a bit more ergonomic with a ppx, if it's a real bother.
<d_bot>
<Gooby> Ah true, although ppxes are kind of intimidating because of their complexitiy
<d_bot>
<Gooby> While we are at it, do you think there is anything we as inexperienced users can contribute to make the progress towards typed effects faster?
<companion_cube>
@Kakadu I'm not too optimistic, the retrocompatibility challenges are real
<companion_cube>
and it's the kind of thing you can only contribute to by doing a PL PhD at gallium
<d_bot>
<Gooby> Crap, oh well haha
<sadiq>
yea, there's PL wizardry beyond my skills involved.
<companion_cube>
it'd put OCaml at the cutting edge of ML
<d_bot>
<Gooby> I think the same, but since OCaml community isn't big it's still a bit sluggish unfortunately
<d_bot>
<Gooby> But since there's nothing I can do, can't be helped
shawnw has quit [Ping timeout: 256 seconds]
<olle>
Wouldn't typed effects infer the most general effect?
<olle>
So amount of code would be same, unless you want to be restrictive
<d_bot>
<Gooby> Well I think if a function performs effects e1,e2...en
<d_bot>
<Gooby> Then those will be in the signature, and then a handler matching on it is either supposed to match each effect to be well typed (otherwise it's a partial function), or else there was a page mentioning an effect system which could potentially maybe "release" that effect into some sort of a global handler which could try handling such effects, as well as the ones like IO
<olle>
But echo to stdout is also an effect
<olle>
Right...?
<d_bot>
<Gooby> I think yes
<olle>
Why would you have to match on IO?
<d_bot>
<Gooby> Nono, I'm not speaking from knowledge here, but there could be some sort of a global handler
<d_bot>
<Gooby> For effects such as IO
<d_bot>
<Gooby> Although that sounds like it might hurt performance a bit
<olle>
Hm
<companion_cube>
this would break every existing program
<companion_cube>
exceptions will not be an effect, for example, afaik
<olle>
Huh?
<d_bot>
<Gooby> Do you think it's viable to make it a compiler option? By default it's backwards compatibility mode, if you enable the option then you get to utilise the new effects system
<d_bot>
<Gooby> That way it's opt in rather than opt out
<companion_cube>
I doubt this would fly
<companion_cube>
it would still fragment the ecosystem into 2 incompatible halves
<companion_cube>
no one wants that
<olle>
Would retrofitting be just implicitly making top function "all" effectful?
<olle>
So you have opt-in typed effects
<companion_cube>
well idk, I remember a talk where `->` was basically made into an arrow with implciit effects? not sure
<olle>
Hm
<companion_cube>
just wait and see what the core team will do
<d_bot>
<Gooby> Well I think based on what I read, the type would be something like `int -[IO]-> int`, but if you don't care about the effect you could disregard it and treat it as `int -> int`
<d_bot>
<Gooby> The only issue is incorporating the system in a way that breaks very little
<olle>
Mm
<olle>
Wish I had more time for OCaml. Sigh.
landonf has joined #ocaml
<Anarchos>
olle we all wish :)
<d_bot>
<Gooby> Haha, if modular implicits were a thing, you could have `perform` implicitly resolve the module based on the effect type, which would also contain the handler
<olle>
Anarchos: True
mro has joined #ocaml
<d_bot>
<Gooby> Actually, since effects are supposed to be passable values, and you can continue as long as you have the continuation k, you should be able to match only on a subset of a function's effects, and if no matches pass the effect and the continuation to some other function which can match further
<d_bot>
<Gooby> My point being, the stl could just define a function to handle predefined effects such as IO, and all you need to do is pass your effect if none matcj
<d_bot>
<Gooby> Though that too would break old code
<d_bot>
<Gooby> So I guess it does not solve the issue, but it might be easier to implement instead of some global handler
<d_bot>
<Gooby> It would also be a bit unergonomic maybe
Guest2263 has quit [Ping timeout: 240 seconds]
spip has joined #ocaml
spip is now known as Guest456
<d_bot>
<mbacarella> workflow sanity check: there are no ocaml IDEs yet that run a compiler in watch mode and when errors are detected you can click on the error and go straight to the error in your editor, right?
<d_bot>
<Anurag> I don't think there is a specific IDE that does that, but quite a few editors will display the errors in a specific window where clicking on them will take you to the error in your editor (vim/neovim/vscode all do this)
<d_bot>
<Anurag> For watch mode you can rely on dune's watch mode. It works really well in my experience
<Fardale>
@mbacarella merlin or ocaml-lsp does this for you, you don't need to leave the editor they will show you the error in the current file directly.
<d_bot>
<Drup> (and almost all editors can use merlin to highlight errors)
<companion_cube>
s/merlin/ocaml-lsp-server/
<qwr>
iirc merlin worked with emacs, ocaml-lsp-server should be good with neovim or some other lsp-oriented editor
SdeSousa has quit [Ping timeout: 256 seconds]
<d_bot>
<mbacarella> right I'm aware. The thing is if you're doing a refactor and change some type places everywhere else in your codebase from the point you just edited need to be fixed, and it would be nice if I had a semi-automatic way to jump to them
<d_bot>
<mbacarella> say what? they show you the errors in a section of your editor and you can jump to the line they're complaining about?
<d_bot>
<mbacarella> have i been using neovim and vscode wrong?
<companion_cube>
neovim + LSP should do that, yes
xiongxin has quit [Quit: xiongxin]
<companion_cube>
in the location window (:lNext and all that) iirc
<d_bot>
<mbacarella> huh.
<d_bot>
<p1xelHer0> if you want the easy way out u can use something like https://github.com/folke/trouble.nvim that groups all kinds of errors and definitions in a neat window
<Corbin>
I wonder to what degree we should consider it a language-design problem to make that sort of refactoring easy.
<d_bot>
<mbacarella> huh. I believe you guys, I guess my environments are always some degree of broken
SdeSousa has joined #ocaml
<companion_cube>
Corbin: you mean, by having strong modularity, sum types, warning on missing fields in patterns, etc.?
<d_bot>
<mbacarella> yeah okay. i'm using vs code on two different computers. in one ocaml project it's showing many, many more errors in "problems" than dune build actually reports.
<d_bot>
<p1xelHer0> nope, this is just a "gamer tag" i came up with when i created my league of legends account 10 years ago 😄 stuck with it since
<d_bot>
<p1xelHer0> i always use the 1 and 0 in the name, its ugly enough that no one "steals" it on the internet
<d_bot>
<Anurag> Trouble is the plugin i use and it works really well with the build in lsp on neovim (like @p1xelHer0 suggested), but there are other plugins like `ale`, `syntastic` etc that will also populate the loclist with diagnostic data.
<d_bot>
<p1xelHer0> yeah, Trouble is "the new kid on the block" or whatever u want to call it. configured with lua, embracing Neovim more
jsoo has joined #ocaml
<companion_cube>
@anurag I had a plugin for lsp<->loclist
<companion_cube>
but it seems that with neovim 0.6 it does it automatically now
<companion_cube>
💃
<Corbin>
companion_cube: For comparison, refactoring in Cammy is done with sed, as a design choice. I'm building a nicer refactoring tool that will let me store docs next to code and only refactor code while not changing docs.
<Corbin>
Modularity is great, but the actual cost of hands on keyboard can't be ignored. (Maybe I'm sensitive to this because I have RSI damage to my hands.)
<companion_cube>
if you can refactor with sed, doesn't this mean you can't shorten names?
<companion_cube>
Foo.Bar.yolo ?
<Corbin>
The syntax doesn't bind any names, so the only names left are the ones for files in a filesystem. Refactoring consists of renaming the file and also replacing the filename in all other files; it's only a couple lines of shell.
<companion_cube>
so how do you refer to a function>
<companion_cube>
?
<Corbin>
I can take "the name" of a function, which is CT jargon; given some function f : X -> Y, its name is [f] : 1 -> (X -> Y).
<companion_cube>
oh well
<companion_cube>
so if you change the type, you have to rename?
<Corbin>
Not necessarily, but probably, yeah. Sometimes the new type is a refinement of the old type; that happened when I changed how the terminal type 1 is implemented. But mostly, if I want a new expression with a new type, I give it a new name and *don't change the old file*, allowing for incremental cleanup.
<reynir>
Opam CI says 'Error: Unbound value Result.iter' in OCaml 4.12, but I think it was introduced in 4.08 and I can't reproduce locally :/
<hannes>
indeed. add 'conflict: [ "result" {< "1.5"} ]' to packages, even if there's no need for result...
<companion_cube>
try Stdlib.Result.iter, anyway?
<reynir>
yea, I added the conflict
mro has quit [Remote host closed the connection]
mro has joined #ocaml
Corbin has quit [Ping timeout: 252 seconds]
Corbin has joined #ocaml
rwmjones_ is now known as rwmjones
SdeSousa has quit [Quit: Client closed]
waleee has quit [Ping timeout: 252 seconds]
mro has quit [Remote host closed the connection]
Anarchos has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
waleee has joined #ocaml
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Anarchos has joined #ocaml
mro has joined #ocaml
waleee has quit [Ping timeout: 240 seconds]
mro has quit [Remote host closed the connection]
bartholin has quit [Quit: Leaving]
mro has joined #ocaml
mbuf has quit [Quit: Leaving]
mro has quit [Remote host closed the connection]
waleee has joined #ocaml
Colt has joined #ocaml
zebrag has joined #ocaml
jlrnick has joined #ocaml
<d_bot>
<Gooby> I meant to ask, since you all have bot markers and cat pfps, I'm guessing you are using a bridge to communicate from a different platform. Which? IRC?
<companion_cube>
yep
<companion_cube>
on libera.chat
<d_bot>
<Gooby> Aah I see
olle has quit [Ping timeout: 252 seconds]
<d_bot>
<Gooby> I've taken a liking to XMPP as opposed to IRC but unfortunately nobody uses XMPP only :/
Anarchos has quit [Quit: Vision[]: i've been blurred!]
Haudegen has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Remote host closed the connection]
zebrag has quit [Quit: Konversation terminated!]
waleee-cl has joined #ocaml
waleee has quit [Read error: Connection reset by peer]
waleee-cl has quit [Client Quit]
waleee has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
Anarchos has joined #ocaml
<d_bot>
<Alistair> Is there a ppx for arrow syntax?
olle has joined #ocaml
rgrinberg has joined #ocaml
gravicappa has quit [Ping timeout: 260 seconds]
jlrnick has quit [Ping timeout: 265 seconds]
mro has quit [Read error: Connection reset by peer]
mro has joined #ocaml
Serpent7776 has quit [Quit: leaving]
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drakonis has left #ocaml [WeeChat 3.1]
Anarchos has quit [Quit: Vision[]: i've been blurred!]
olle has quit [Ping timeout: 256 seconds]
mro has quit [Read error: Connection reset by peer]
mro_ has joined #ocaml
mro_ has quit [Quit: Leaving...]
Haudegen has quit [Quit: No Ping reply in 180 seconds.]
Haudegen has joined #ocaml
Anarchos has joined #ocaml
<d_bot>
<Et7f3> What kind of transformation you want ?
<d_bot>
<rgrinberg> There’s not. I’m curious why you’d want it, it’s extremely uncommon even in Haskell
Guest8 has joined #ocaml
<Guest8>
the line "type a' merkelTree" gives a syntax error on "merkelTree" as the first line in my .mli file
<Guest8>
am I missing something to declare a type that takes a variable ?
<companion_cube>
it's 'a
<companion_cube>
not a'
* Anarchos
dreams of unicode rendering where type variables are greek letters
Guest8 has quit [Quit: Client closed]
Guest8 has joined #ocaml
CoolerVoid has quit [Quit: Client closed]
<companion_cube>
they're harder to input for most of us
<Guest8>
ok that is something that the compiler should be able to point out
<companion_cube>
probably not, it's a lexer error at this point
<companion_cube>
it's like writing "foo and never close the "
<companion_cube>
not that easy to give a good error message
<d_bot>
<NULL> a' is an ident, so a valid token
<d_bot>
<NULL> I'm pretty sure the parser is the one complaining
Anarchos has quit [Quit: Vision[]: i've been blurred!]
<companion_cube>
oh my bad @NULL
<companion_cube>
you're right, foo' works
<companion_cube>
so the parser must complain about merkelTree not being expected
<d_bot>
<NULL> In any case, both the lexer and the parser should be able to report on why the input is wrong (using an exception table for the parser), it just needs a lot of work