companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.12 released: https://ocaml.org/releases/4.12.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
olle has quit [Ping timeout: 250 seconds]
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
Stumpfenstiel has quit [Ping timeout: 258 seconds]
Haudegen has quit [Ping timeout: 250 seconds]
berberman has quit [Ping timeout: 246 seconds]
waleee has quit [Ping timeout: 272 seconds]
berberman has joined #ocaml
<d_bot> <thangngoc89> What do you recommend for someone who knows ocaml's typesystem but doesn't know its ecosystem?
<d_bot> <thangngoc89> I get lost at doing basic things like file access, file tree walk, ...
<d_bot> <thangngoc89> I'm experimenting with building a toy server with dream
glassofethanol has quit [Ping timeout: 258 seconds]
vicfred_ has joined #ocaml
<companion_cube> most of that should be in lwt
<companion_cube> look at lwt's doc and you should be good
vicfred has quit [Ping timeout: 268 seconds]
minwuekim has quit [Read error: Connection reset by peer]
<d_bot> <thangngoc89> @companion_cube ah. I'm looking at `CCIO` right now and t he docs does mention about looking at `Lwt` for more advanced stuff. So I suppose that I should do all `i/o` operations with lwt's relevant libraries instead of `CCIO` ?
minwuekim has joined #ocaml
<companion_cube> well, if you write a server, probably
<companion_cube> i.e. if you want async IO everywhere
<companion_cube> CCIO is a helper for, well, blocking IOs as performed in other kinds of programs
<d_bot> <thangngoc89> @companion_cube thank you very much. I do want async IO everywhere for my toy server.
<d_bot> <thangngoc89> So another question, is there any high level IO libraries for Lwt ?
<d_bot> <thangngoc89> Lwt_io is kinda primitives and google search doesn't yield anything on my side (probably I didn't search about ocaml for while now)
<companion_cube> hum, I'm not aware of anything _on top_ of lwt
<companion_cube> what would you call "high level"?
<d_bot> <thangngoc89> I thinking of "common" fs operations like walk tree, `copy`, `move`, `read`, `mkdir -p` , `stats`, `file exists` , ....
<companion_cube> read, like read a whole file?
<companion_cube> a lot of what you mention is in Unix or Lwt_unix
<d_bot> <thangngoc89> oh. I though `Lwt_io` would contain the api
<d_bot> <thangngoc89> thank you. I will read `Lwt_unix`
<companion_cube> copy, though, is higher level so it's not there
<companion_cube> it doesn't correspond to a classic unix API
<d_bot> <thangngoc89> @companion_cube that's the kind of "higher level" api I'm talking about 🙂 .
<companion_cube> a blocking version exists in fileutils, I think
<companion_cube> but `copy` isn't as trivial as it looks
<companion_cube> can be implemented in different ways, have confusing semantics (if you have symlinks for example)
<d_bot> <thangngoc89> I've read most of Unix system programing in Ocaml (https://ocaml.github.io/ocamlunix/ocamlunix.html) . I think that would be a good place to start building my own fs functions.
<d_bot> <thangngoc89> Thank you again for your help.
<companion_cube> if you make a library on top of lwt, I'm sure people will be interested :)
<companion_cube> for completeness I should add that a lot of filesystem operations are not actually async on linux
<companion_cube> (not sure `stat` is, for example)
<companion_cube> so lwt has to resort to a thread pool. but people are working on using io_uring for that
<d_bot> <thangngoc89> I don't think I have any experiences with making library (the publishing progress is intimidating)
<companion_cube> oh, also!! check out `luv`
<companion_cube> it's libuv, which powers node.js, but for lwt.
<companion_cube> and by aantron, who's been a long time maintainer of lwt and overall an awesome programmer
<d_bot> <thangngoc89> looks like aantron builds everything
<companion_cube> bindings to libuv* I should say
<d_bot> <thangngoc89> I'm using `dream`, `lambdasoup`
<d_bot> <Anurag> If you are starting with lwt and want higher level apis for things, i think sticking with `Lwt_io` is a good default as a beginner.
<companion_cube> he's not the only one, but he weights in the lwt ecosystem yeah
<d_bot> <Anurag> You would've seen `in_channel` and `out_channel` in the `Unix system programing in Ocaml ` book, and the `Lwt_io` api should look familiar (except it'll be promise based)
<d_bot> <thangngoc89> yeah. I'm not sure why but I don't like `Async` that much probably because of the opaque release process.
<companion_cube> but it's not super high level :)
<d_bot> <thangngoc89> I'm using `ccontainers` and `lwt`
<d_bot> <thangngoc89> but still a total beginners. I was a hard bucklescript user last time
<d_bot> <Anurag> `Async` is also a very nice library, but if you are starting with lwt i'd say just stick with it for now 🙂
<companion_cube> well if it's to use dream, lwt is mandatory anyway
<d_bot> <Anurag> for sure
<d_bot> <thangngoc89> it's true
<d_bot> <thangngoc89> Using 100% ocaml stack to develop ocaml
<d_bot> <thangngoc89> (editor is oni2)
<companion_cube> oh, how is it?
<d_bot> <thangngoc89> it's good but still buggy
<d_bot> <thangngoc89> sufficient for daily usage
<d_bot> <thangngoc89> I'm using a local build so I can drop in and fix minor issues myself
<companion_cube> :D awesome
<d_bot> <thangngoc89> I can't stand VS Code delays in character input
<companion_cube> I stick with nvim personally, but go you
<d_bot> <thangngoc89> ocaml&reason is first class, everything just works
<companion_cube> and they use revery for the GUI?
<d_bot> <thangngoc89> yes. they developed revery for oni2
<d_bot> <thangngoc89> it uses skia under the hood
<d_bot> <thangngoc89> to draw on the screen
<companion_cube> so it's really from scratch? dang
<d_bot> <thangngoc89> yup. really from scratch !
<d_bot> <thangngoc89> you should try it
<companion_cube> does it use skia for font rendering too?
<companion_cube> sorry, I'm an old vim user, I can't
<d_bot> <thangngoc89> I see. before oni, I only use vim for ssh to remote server. oni's speed is what hooked me
<d_bot> <thangngoc89> sublime speed + vscode ecosystem
<d_bot> <thangngoc89> RE: font. I think revery uses skia for everything UI related. but it's abstracted away nicely in ocaml/reason api
<d_bot> <thangngoc89> I never have to touch skia
<companion_cube> right
mbuf has joined #ocaml
vicfred_ has quit [Quit: Leaving]
insep has quit [Read error: Connection reset by peer]
insep has joined #ocaml
insep has quit [Read error: Connection reset by peer]
insep has joined #ocaml
insep has quit [Read error: Connection reset by peer]
<d_bot> <thangngoc89> How would I put inline svg element in html ?
<d_bot> <thangngoc89> ```
<d_bot> <thangngoc89> Error: This expression has type ([> Svg_types.svg ] as 'a) Svg.elt list
<d_bot> <thangngoc89> but an expression was expected of type
<d_bot> <thangngoc89> ([> Html_types.img ] as 'b) Html5.elt list
<d_bot> <thangngoc89> Type 'a Svg.elt is not compatible with type 'b Html5.elt
<d_bot> <thangngoc89> ```
<d_bot> <thangngoc89> This is the error when I try to do that
wilfred has joined #ocaml
<d_bot> <thangngoc89> Got it. Use `Tyxml.Html.Svg` instead of `Tyxml.svg`
cedric has joined #ocaml
shawnw has joined #ocaml
Serpent7776 has joined #ocaml
Tuplanolla has joined #ocaml
cedric has quit [Quit: Konversation terminated!]
cedric has joined #ocaml
dhil has joined #ocaml
wilfred has quit [Quit: Connection closed for inactivity]
EmoSpice has quit [*.net *.split]
EmoSpice6 has joined #ocaml
Haudegen has joined #ocaml
jinsun has quit [Ping timeout: 252 seconds]
yoctocell has joined #ocaml
bartholin has joined #ocaml
<micro> Hi. The cert at https://opam.ocaml.org expired today at 07:16 GMT
<micro> Looks like Lets Encrypt auto renewal didn't happen.
gravicappa has joined #ocaml
<sim642> Oof
waleee has joined #ocaml
vizard has joined #ocaml
gravicappa has quit [Read error: Connection reset by peer]
gravicappa has joined #ocaml
bartholin has quit [Ping timeout: 268 seconds]
bartholin has joined #ocaml
<d_bot> <Cyclomatic Complexity> is there an easy ppx that adds syntax to write a function on arbitrary sized tuples with some syntax like variadic args, and which specializes it into its `regular_fun`, `fun_1`, `fun_2`, `fun_3`, etc. variants?
Nahra has quit [Remote host closed the connection]
<d_bot> <Cyclomatic Complexity> right now, i am having a `Tuple_2`, `Tuple_3`, etc. modules with code duplication, but this is bad wrt maintenance and possible bugs
cross has quit [Quit: leaving]
<d_bot> <Cyclomatic Complexity> or, dirtier, but is there a ppx that lets one define macros?
<d_bot> <ggole> MetaOCaml would be one approach to specialiastion
waleee has quit [Ping timeout: 250 seconds]
cross has joined #ocaml
cross has quit [Quit: leaving]
cross has joined #ocaml
cross has quit [Client Quit]
cross has joined #ocaml
<d_bot> <Cyclomatic Complexity> would it work with variadic tuples? it looks this either requires a stronger type system, or syntactic macros
<d_bot> <ggole> Yes, you could range over the types of tuples with GADTs
<d_bot> <ggole> Up to a fixed size, anyway
dmbaturin has quit [Quit: let (+) 2 2 = 5 in 2 + 2]
Nahra has joined #ocaml
<d_bot> <Cyclomatic Complexity> by chance, do you have a toy example showing what it would look like?
dmbaturin has joined #ocaml
<d_bot> <ggole> ```ocaml
<d_bot> <ggole> type _ tuple_descriptor =
<d_bot> <ggole> | T2 : ('a * 'b) tuple_descriptor
<d_bot> <ggole> | T3 : ('a * 'b * 'c) tuple_descriptor
<d_bot> <ggole> | T4 : ('a * 'b * 'c * 'd) tuple_descriptor
<d_bot> <ggole> (* etc *)
<d_bot> <ggole>
<d_bot> <ggole> let tuple_id : type t. t tuple_descriptor -> t -> t =
<d_bot> <ggole> fun descr tuple ->
<d_bot> <ggole> match descr, tuple with
<d_bot> <ggole> | T2, (a, b) -> (a, b)
<d_bot> <ggole> | T3, (a, b, c) -> (a, b, c)
<d_bot> <ggole> | T4, (a, b, c, d) -> (a, b, c, d)
<d_bot> <ggole> ```
<d_bot> <ggole> With the idea that MetaOCaml can specialise the tags and dispatch away
dmbaturin has quit [Remote host closed the connection]
<d_bot> <Drup> @Cyclomatic Complexity do you really need the tuples ? Could you do with heterogeneous lists ?
<d_bot> <Cyclomatic Complexity> it looks like you still need to duplicate the code processing the content for each tuple size
<d_bot> <Cyclomatic Complexity> let me check heterogeneous lists and i'll tell you 😄
jinsun has joined #ocaml
<d_bot> <Cyclomatic Complexity> @Drup Are heterogeneous lists the things with GADT-typed cons/nil lists? If so, it doesn't work, as accessing a latter element is O(N)
<d_bot> <Cyclomatic Complexity> might not be a problem in practice tho
<d_bot> <Cyclomatic Complexity> is there a good lib for heterogeneous lists?
<d_bot> <Drup> Not to my knowledge, because the pattern is usually heavily customized depending on the use case, but it's more or less 20 lines to write the base stuff
<d_bot> <Drup> It's indeed O(N) in theory, I wonder if we could do something about that ....
<d_bot> <Drup> that being said, if it's really used like a tuple, N < 10, so that's moot
<d_bot> <Cyclomatic Complexity> yup
<d_bot> <Cyclomatic Complexity> yeah, but the interesting stuff are the combinators and the right abstractions for them
<d_bot> <Drup> Not really, no. You just use them as lists, there are very few generic functions you can write on them
<d_bot> <Drup> (just like .... tuples)
<d_bot> <ggole> Yeah, you'd write one function like that (or a few) and use it to define a bunch of operations
<d_bot> <ggole> Not that tuples have a lot of operations to define
<d_bot> <Drup> the nice part is using the lists syntax for them:
<d_bot> <Drup> ```
<d_bot> <Drup> type (_,_) t = [] of ('a,'a) t | (::) of 'a * ('b,c) t -> ('a -> 'b,'c) t
<d_bot> <Drup> ```
<d_bot> <Drup>
<d_bot> <Drup> And then you can use pattern matching:
<d_bot> <Drup> ```
<d_bot> <Drup> let foo [ a ; b ; c] = .... (* this function only takes a 3 pseudo-tuple *)
<d_bot> <Drup> ```
<d_bot> <Drup> Or variadically:
<d_bot> <Drup> ```
<d_bot> <Drup> let bar : type a b. (a,b) t -> ... = function
<d_bot> <Drup> | [] -> ...
<d_bot> <Drup> | [ a ; b ] -> ... (* case 2 *)
<d_bot> <Drup> | x :: t -> ...
<d_bot> <Drup> ```
bartholin has quit [Ping timeout: 268 seconds]
dmbaturin has joined #ocaml
bartholin has joined #ocaml
TakinOver has quit [Read error: Connection reset by peer]
Stumpfenstiel has joined #ocaml
octachron has quit [Quit: ZNC 1.8.2 - https://znc.in]
octachron has joined #ocaml
octachron has quit [Client Quit]
octachron has joined #ocaml
Nahra has quit [Remote host closed the connection]
tizoc has quit [Quit: Coyote finally caught me]
tizoc has joined #ocaml
bartholin has quit [Ping timeout: 268 seconds]
bartholin has joined #ocaml
<d_bot> <inkbottle> I'm trying to have that working: https://github.com/ocaml/ocaml-lsp/pull/399
Nahra has joined #ocaml
<d_bot> <inkbottle> `emacs` `M-x merlin-refactor-open-qualify` (`lsp-mode`), opens a long list of possible completions, probably a mode conflict. Otherwise does nothing. The following is working:
<d_bot> <inkbottle> ```esy ocamlmerlin single refactor-open -position 2:1 -action qualify -filename ./bin/server/main.ml < ./bin/server/main.ml | jq .```
mbuf has quit [Quit: Leaving]
<d_bot> <inkbottle> Okay, the commits are not merged yet: https://github.com/ulugbekna/ocaml-lsp/tree/refactor-open
<d_bot> <inkbottle> And `merlin` is not meant to be compatible with `ocaml-lsp` anymore.
oriba has joined #ocaml
insep has joined #ocaml
minwuekim has quit [Remote host closed the connection]
minwuekim has joined #ocaml
<d_bot> <Cyclomatic Complexity> hi, i'm trying to do very basic things with variance and shadow types in https://pastebin.com/XvZTvJT0
<d_bot> <Cyclomatic Complexity> but when i add a variance annotation on `'a mode`, i get errors
<d_bot> <Cyclomatic Complexity> "The variance of some parameters can not be checked"
<d_bot> <Cyclomatic Complexity> also, big what: `let f : < bind ; listen > mode -> < bind > mode = fun x -> (x :> < bind > mode)` -> `< bind ; listen > mode is not a subtype of < bind > mode. The second object type has no method listen`. ok. so be it, it makes sense.
<d_bot> <Cyclomatic Complexity> but also: `let f : < bind > mode -> < bind ; listen > mode = fun x -> (x :> < bind ; listen > mode)` -> `< bind ; listen > mode is not a subtype of < bind > mode. The first object type has no method listen`. wat, nooooooooooo
<d_bot> <Cyclomatic Complexity> which direction is it?
bartholin has quit [Ping timeout: 265 seconds]
<d_bot> <octachron> The type constructor `mode` is invariant in its parameter `'a`. Thus, knowing that `'a` is a subtype of `'b`, tell you nothing about `'a t` and `'b t`.
<d_bot> <Cyclomatic Complexity> But why can't I make it covariant then?
<d_bot> <octachron> Because it is unsound to make GADT covariant or contravariant.
<d_bot> <Cyclomatic Complexity> Is there any resource about this? i don't think https://ocaml.org/manual/polymorphism.html covers it
bartholin has joined #ocaml
<d_bot> <octachron> The problem is that GADTs carry type equations, and if one were allowed to transform only one side of the equation with subtyping that would be unsound.
<d_bot> <octachron> Typically, with `type ('a,'b) eq = Refl: ('a,'a) eq `, coercing `(<a:int>,<a:int>) eq` to `(<>, <a:int>)` eq is unsound.
<d_bot> <octachron> For a more detailed explanation: https://arxiv.org/abs/1301.2903
yomimono has quit [Ping timeout: 250 seconds]
<d_bot> <octachron> A simpler encoding that does not rely on variance: https://sketch.sh/s/0cutJ6r0R3JQekYAmXOweN
yomimono has joined #ocaml
dwt_ has quit [Ping timeout: 252 seconds]
waleee has joined #ocaml
bartholin has quit [Ping timeout: 268 seconds]
zebrag has joined #ocaml
bartholin has joined #ocaml
shawnw has quit [Ping timeout: 250 seconds]
vb has quit [Ping timeout: 265 seconds]
vb has joined #ocaml
<d_bot> <Cyclomatic Complexity> nice, thanks
unyu has joined #ocaml
<dmbaturin> unyu: Have you moved to here recently, or I just haven't seen you since I moved in myself?
sagax has quit [Remote host closed the connection]
<unyu> dmbaturin: I joined this channel only relatively recently. But I moved from Freenode to Libera Chat rather early.
<dmbaturin> Ah, I see. I was quite early to move as well.
eight has joined #ocaml
bartholin has quit [Ping timeout: 252 seconds]
gravicappa has quit [Ping timeout: 268 seconds]
bartholin has joined #ocaml
insep has quit [Read error: Connection reset by peer]
insep has joined #ocaml
insep has quit [Read error: Connection reset by peer]
insep has joined #ocaml
oriba has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
yoctocell has quit [Ping timeout: 265 seconds]
shawnw has joined #ocaml
elf_fortrez has joined #ocaml
hockpa2e has joined #ocaml
dhil has quit [Ping timeout: 258 seconds]
jinsun has quit [Ping timeout: 265 seconds]
cedric has quit [Quit: Konversation terminated!]
elf_fortrez has quit [Quit: Client closed]
bartholin has quit [Ping timeout: 272 seconds]
bartholin has joined #ocaml
aquijoule_ has quit [Remote host closed the connection]
<d_bot> <Cyclomatic Complexity> thanks @roddy
favonia has joined #ocaml
vizard has quit [Ping timeout: 265 seconds]
<d_bot> <Ulugbek> Hi. The easiest way to get that working is to pin that branch. LSP clients such as lsp-mode in Emacs and vscode-ocaml-platform in vscode should have support in the form of code actions. You're right that ocaml-lsp doesn't need merlin installed separately because ocaml-lsp vendors merlin
<d_bot> <Ulugbek> Does anybody have any idea what can be wrong with opam? I just installed it with `brew` and `opam init`ed.
<d_bot> <Ulugbek>
<d_bot> <Ulugbek> ```
<d_bot> <Ulugbek> $ opam switch list-av
<d_bot> <Ulugbek> # Listing available compilers from repositories: default
<d_bot> <Ulugbek> # No matches found
<d_bot> <Ulugbek> ```
<d_bot> <octachron> If you are on MacOs/Arm, you might be missing an `opam update` (since it is possible that there is no compatible compiler in the initial repo state)
bartholin has quit [Quit: Leaving]
favonia has quit [Ping timeout: 250 seconds]
favonia has joined #ocaml
Stumpfenstiel has quit [Ping timeout: 268 seconds]
richbridger has joined #ocaml
Haudegen has quit [Ping timeout: 272 seconds]
insep has quit [Ping timeout: 272 seconds]
richbridger has quit [Remote host closed the connection]
richbridger has joined #ocaml
oriba has joined #ocaml
oriba has quit [Client Quit]
insep has joined #ocaml
favonia has quit [Ping timeout: 272 seconds]
Tuplanolla has quit [Quit: Leaving.]