companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.0 released(!!1!): https://ocaml.org/releases/5.0.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
azimut has quit [Ping timeout: 246 seconds]
<discocaml> <Kali> ```ocaml
<discocaml> <Kali> let hashtbl_of_list l =
<discocaml> <Kali> let hashtbl = Hashtbl.create 0 in
<discocaml> <Kali> List.iter (fun (k,v) -> Hashtbl.add hashtbl k v) l;
<discocaml> <Kali> hashtbl
<discocaml> <Kali> ```
<discocaml> <Kali> as for your list to hashtable problem
<discocaml> <regularspatula> Not a bad idea to avoid point free
<technomancy> Kali: not a problem exactly; just wanted to know if I was doing things wrong
<discocaml> <Kali> that is reasonable
dnh has joined #ocaml
waleee has quit [Ping timeout: 246 seconds]
waleee has joined #ocaml
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<discocaml> <lyhokia> Hello, any one knows how should I remodel 2 mutual recursive GADTs that parametrized over row types so that I can map between different instances of the 2 GADTs?
<discocaml> <lyhokia> I know this is a bit abstract so I have a snippet here: https://pastebin.ubuntu.com/p/P9WksDnRMH/
<discocaml> <lyhokia> The essential problem with this is: say I have 2 mutual recursive GADT a and b, I can't produce a f a -> f' a from f b -> f' b, because in some instance of b it may not be mutual recursive at all because we can mark some alt in b two explicitly remove such possibility
<discocaml> <lyhokia> like this:
<discocaml> <lyhokia> ```ocaml
<discocaml> <lyhokia> type ('dep, 'sur) inner =
<discocaml> <lyhokia> | Many: 'dep inner list -> ('dep, 'sur) inner
<discocaml> <lyhokia> | Just: int -> ('dep, 'sur) inner
<discocaml> <lyhokia> | Out: 'dep gen2 -> ('dep, 'sur) inner
<discocaml> <lyhokia> and 'k inner_gen = ('k, 'k) inner
<discocaml> <lyhokia>
<discocaml> <lyhokia> and ('dep, 'sur) flex2 =
<discocaml> <lyhokia> | Val: int
<discocaml> <lyhokia> -> ('dep, 'sur) flex2
<discocaml> <lyhokia> | If: 'dep gen2 * 'dep gen2 * 'dep gen2
<discocaml> <lyhokia> -> ('dep, <has_if: yes; ..> as 'sur) flex2
<discocaml> <lyhokia> | In: 'dep inner_gen
<discocaml> <lyhokia> -> ('dep, <has_in: yes; ..> as 'sur) flex2
<discocaml> <lyhokia>
<discocaml> <lyhokia> and 'k gen2 = ('k, 'k) flex2
<discocaml> <lyhokia> ```
<discocaml> <lyhokia> whether or not this is mutual recursive depends on the param passed to the GADT
<technomancy> uh oh
<technomancy> the lsp install instructions involve editing ~/.bash_profile
<technomancy> that's ... going to cause problems
<technomancy> "programs launched from this shell can have access to it but not from that shell"
<technomancy> I've seen that coming from beginners more times than I can count
<technomancy> *especially* when it's a program launched behind the scenes by the editor and not invoked directly by the user
waleee has quit [Ping timeout: 246 seconds]
<technomancy> but if you do install it, it seems to be pretty nice
<technomancy> much, much easier than configuring the emacs tooling I tried back in 2014 last time I was messing around with this
<technomancy> probably best to tell them to sudo ln -s $HOME/.opam/default/bin/ocamllsp /usr/local/bin
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
<discocaml> <Kali> lyhokia: #advanced-help, and don't post long multi-line message on the irc bridge because it sends an individual message for each
rom1504 has quit [Ping timeout: 258 seconds]
rom1504 has joined #ocaml
chrisz has quit [Ping timeout: 245 seconds]
chrisz has joined #ocaml
<discocaml> <.korven.> neovim yup, he'd die by neovim so it's def safe to say he doesn't hate it XD
azimut has joined #ocaml
_whitelogger has joined #ocaml
bartholin has joined #ocaml
mima has joined #ocaml
spip has quit [Quit: Konversation terminated!]
dnh has joined #ocaml
ursa-major has quit [Ping timeout: 260 seconds]
curium has quit [Quit: Gateway shutdown]
dnh has quit [Client Quit]
ursa-major has joined #ocaml
ursa-major has quit [Client Quit]
<cedb> what do you think is better for generating dockerfiles? dsl, template or just direct generation from config file
dnh has joined #ocaml
Tuplanolla has joined #ocaml
rom1504 has quit [Ping timeout: 255 seconds]
rom1504 has joined #ocaml
pieguy128 has quit [Server closed connection]
pieguy128 has joined #ocaml
<toastal> cedb: Nix can build them, no?
Serpent7776 has joined #ocaml
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<discocaml> <._null._> technomancy: would you not be fine with VSCodium? That's what I use, to have a beginner-friendly editor without telemetry
mima has quit [Ping timeout: 244 seconds]
rgrinberg has joined #ocaml
azimut_ has joined #ocaml
azimut has quit [Ping timeout: 246 seconds]
uncomfy has joined #ocaml
<discocaml> <darrenldl> how much faster is iter compared to seq?
<discocaml> <darrenldl> bit of a silly question nvm
<companion_cube> With flambda it can be quite a bit faster, if all the combinators inline
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mima has joined #ocaml
infinity0 has quit [Ping timeout: 246 seconds]
<pgiarrusso> 3:20 AM <technomancy> "programs launched from this shell can have access to it but not from that shell"
<pgiarrusso> Are those chaChanges to env vars usually belong in .profile and must be exported from there — non-login shells
<pgiarrusso> *changes to env vars belong in . profile, non-login shell should inherit them
<pgiarrusso> I agree that any change to shell init files is a minefield because so much is system-dependent and most users don't understand the local protocol
waleee has joined #ocaml
<pgiarrusso> OTOH, each bash only loads one init file; loading .bashrc in login shell is the job of .bash_profile, and I won't be surprised if sb messes that up.
mima has quit [Ping timeout: 258 seconds]
rgrinberg has joined #ocaml
dnh has joined #ocaml
bartholin has quit [Quit: Leaving]
tizoc has quit [Quit: Coyote finally caught me]
tizoc has joined #ocaml
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
reynir has joined #ocaml
masterbu1lder has quit [Server closed connection]
masterbuilder has joined #ocaml
dnh has joined #ocaml
azimut_ has quit [Ping timeout: 246 seconds]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<discocaml> <ambulatory_amoeba> Are there any decent SQL mapper libs besides caqti/ppx_rapper? Seems like this is the only one people actually use these days
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
azimut has joined #ocaml
John_Ivan_ has joined #ocaml
<cedb> toastal: ya ideally id convince my boss but he just loveees centos
<toastal> you can use Nix to build containers even if you can't go NixOS
<cedb> they also wont let me have sudo and think anything invented/built less than 30 years ago is shiny fashion
<cedb> to be clear, i agree, nix/guix are the only sort of sane way to handle all this nonsense
dnh has joined #ocaml
<dh`> to be fair, sudo has an abysmal security record
John_Ivan_ has quit [Ping timeout: 246 seconds]
bartholin has joined #ocaml
<technomancy> pgiarrusso: over years and years I've just observed that this has caused so much frustration on various IRC channels that it's become a bit of a red flag. even advanced users get mixed up about the difference between .profile, .bash_profile, .bashrc etc and most GUI environments ignore the settings you add there
<dh`> your mistake is using bash
<technomancy> dh`: oh, hell no; I don't use bash
<technomancy> my students do tho
<dh`> I have never understood why bash is the linux default and apparently preferred by the community that way
<technomancy> well, the one thing all the defaults have in common is that they aren't very good, so in that way it fits
uncomfy has quit [Remote host closed the connection]
<technomancy> ._null._: oh, yeah vs codium definitely an option. didn't microsoft break the compatibility of the plugin repository with codium tho? wouldn't be a problem for me but it complicates recommending it to my students.
<discocaml> <._null._> Yes, the plugin repository is a different one, but all OCaml-related extensions are present in both
<technomancy> ah, ok; that's cool. is it fairly common among extension publishers to dual-publish?
<discocaml> <._null._> I think pretty much only Microsoft closed-source code is only available to VSCod
<technomancy> that's good to hear =)
<discocaml> <._null._> e*
<discocaml> <._null._> open-vsx (the alternate repo) has made it really easy to double-publish
<technomancy> https://open-vsx.org/extension/ocamllabs/ocaml-platform I saw this mentioned in the Cornell book; is this the one I should recommend?
rgrinberg has joined #ocaml
<discocaml> <._null._> even for a 3rd party if the extension is open source IIRC
<technomancy> some languages extensions split up the LSP vs regular syntax support for some reason but this looks to be all-in-one?
<technomancy> (side note: I can't believe vs code is supposed to be the "flagship" of LSP but doesn't let you just connect to an LSP server of your choice without a plugin; how ridiculous is that)
<discocaml> <._null._> Yes, that's the OCaml extension
<technomancy> ok, I'm extremely confused. been searching for like ten minutes to figure out how to get indentation working in vs code/codium and apparently it just ... isn't a thing?
<technomancy> either I'm missing something obvious or you can't indent the current line correctly; tab just inserts tab characters, and if you want your indentation to be fixed you have to just reformat the entire file? that can't be right
myrkraverk_ has quit [Ping timeout: 246 seconds]
noddy has quit [Quit: WeeChat 4.0.3]
noddy has joined #ocaml
<discocaml> <jumpnbrownweasel> With an LSP, reformat usually happens on save/write, and you often have to configured it to do that. For example in my Helix `languages.toml` config I have the following. You'd have to look to see how to do it for your editor.
<discocaml> <jumpnbrownweasel> ```
<discocaml> <jumpnbrownweasel> [[language]]
<discocaml> <jumpnbrownweasel> name = "ocaml"
<discocaml> <jumpnbrownweasel> auto-format = true
<discocaml> <jumpnbrownweasel>
<discocaml> <jumpnbrownweasel> [[language]]
<discocaml> <jumpnbrownweasel> name = "ocaml-interface"
<discocaml> <jumpnbrownweasel> auto-format = true
<discocaml> <jumpnbrownweasel> ```
<discocaml> <jumpnbrownweasel> Also note there is an #editor-support channel.
<discocaml> <jumpnbrownweasel> With an LSP, reformat usually happens on save/write, and you often have to configure it to do that. For example in my Helix `languages.toml` config I have the following. You'd have to look to see how to do it for your editor.
<discocaml> <jumpnbrownweasel> ```
<discocaml> <jumpnbrownweasel> [[language]]
<discocaml> <jumpnbrownweasel> name = "ocaml"
<discocaml> <jumpnbrownweasel> auto-format = true
<discocaml> <jumpnbrownweasel>
<discocaml> <jumpnbrownweasel> [[language]]
<discocaml> <jumpnbrownweasel> name = "ocaml-interface"
<discocaml> <jumpnbrownweasel> auto-format = true
<discocaml> <jumpnbrownweasel> ```
<discocaml> <jumpnbrownweasel> Also note there is an #editor-support channel.
<discocaml> <jumpnbrownweasel> Oh, I see you're in the IRC so you don't have that channel. And sorry for posting a multiline response here.
<technomancy> no worries
<technomancy> I guess it doesn't matter for this class since everyone is working on their own, but for professional use, reformatting the whole file on save is a good way to get blamed for code you didn't write!
<technomancy> in any case, auto-format (for the whole file) has no effect anyway, so I was hoping for a simpler solution, but it sounds like none exists in vs code
<companion_cube> Ohai technomancy
<pgiarrusso> You can commit formatting settings to the repo so they're consistent across devs — at least it works well with vscode for C++
<technomancy> so what you're saying is if I want to get away with writing bad code, all I have to do is format it incorrectly, and then my vsode-using co-workers will have to take the fall? =)
<discocaml> <._null._> ocamlformat is not dependent on any editor
<technomancy> hm; ok, so ocamlformat appears to have no effect either
<technomancy> it's just echoing back the input I give it
<discocaml> <_terence_> Is it possible to make the compiler refuse any non purely functional code for select source files ?
<discocaml> <._null._> ocamlformat needs a config file (possibly empty) to work
<discocaml> <._null._> The compiler doesn't know what us purely functional or not (hence why we have value restriction)
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<discocaml> <_terence_> Is it not trivial to check ? Like forbidding all oop constructs and ref syntax ? I'd guess you would need to also annotate some functions you have no control over
<technomancy> an empty config file?
<technomancy> lol, weird but ok; will try that
<technomancy> why not say so instead of suddenly acting like cat
<discocaml> <._null._> You'd have to need annotations for all libraries
<discocaml> <._null._> technomancy: to be compatible with the LSP I guess
<discocaml> <_terence_> Right but doable if you only use the stdlib ? 😗
dnh has joined #ocaml
John_Ivan_ has joined #ocaml
<companion_cube> There is no purity check in the compiler
<companion_cube> Nothing exposed anyway
spip has joined #ocaml
<discocaml> <regularspatula> Technomancy: what editor are you recommending to your students ?
<technomancy> regularspatula: vscodium (grudgingly) and emacs (for advanced students)
<discocaml> <regularspatula> Why grudgingly, is it giving them troubles?
yosik has joined #ocaml
<discocaml> <regularspatula> Emacs for advanced students is interesting (advanced as in those who already know it, or who you think could learn it okay)?
<technomancy> philosophically I don't like the monopolization of developer tools where one company controls everything, practically its indentation behavior is very bad
<discocaml> <regularspatula> I see
<technomancy> more the latter (re: emacs), when I think they will not have much trouble with the core material and have more bandwidth to pick up new things
<technomancy> but I've observed IRC channels for many decades and have seen a lot of people get very frustrated when trying to learn emacs and a language at the same time, so I'm definitely cautious
<discocaml> <regularspatula> We have to teach programming to grad students but who are rank beginners to programming and I never know what’s best to recommend for editors
<discocaml> <regularspatula> Everyone has different OS too
<technomancy> well, emacs is its own os luckily, so ... =)
<discocaml> <regularspatula> Haha great point
<technomancy> but yeah, in general recommending emacs to newbies is a bad idea; I would only do it in special cases
<technomancy> and you probably shouldn't do it unless you're personally willing to provide support
<discocaml> <regularspatula> Yeah I agree with that
<technomancy> (coming from someone who is about to enter their second decade of emacs use)
<technomancy> I maintain my own programming language and we have an excellent LSP implementation but there's no way to connect it to VS Code without someone writing a plugin for it, and none of the core contributors actually use VS Code so it's really frustrating that we can't recommend it for newbies
<discocaml> <regularspatula> Btw, are you technomancy the leiningen dev?
<technomancy> yes
<technomancy> and also https://fennel-lang.org dev more these days =)
<discocaml> <regularspatula> Oh wow, that’s cool. Used lein a bunch back in the day
<companion_cube> technomancy: opinions on using lua/fennel to dynamically extend ocaml programs? :)
<technomancy> haha, uhhh
<technomancy> sounds fun!
<technomancy> no idea how you would do that, but you definitely should give it a try
<companion_cube> A colleague misses clojure in some cases, and I also miss some sort of interactivity
<companion_cube> I'm thinking ppx deriving lua + the existing lua bindings
<companion_cube> But idk if it'd work in practice
<technomancy> yes, having a repl in the program as it runs can be such a pleasure
<companion_cube> Yeah, I get that
<companion_cube> There's just no good way to do it with ocaml
<technomancy> I guess the tricky bit is bridging the types, turning records into tables and back, etc
<technomancy> my surface-level understanding of ocaml is enough to understand that this would be extremely difficult
<technomancy> unless you just want to shuffle around strings or something
<technomancy> I guess maybe if you've already implemented json interfaces for various types it might be easy
<technomancy> is it true to say that parens are only used for grouping and tuples in the syntax?
infinity0 has joined #ocaml
<technomancy> like `foo(xyz)` technically works, but only because you're "grouping" xyz with itself/nothing?
<discocaml> <Kali> for ocaml?
<technomancy> right, yeah
<companion_cube> Yeah
<companion_cube> They're not even required for tuples
xmachina has joined #ocaml
<discocaml> <Kali> parens are only necessary for destructuring in a definition, applying functors, units, and types with multiple variables
<discocaml> <Kali> and for multi-argument constructors
<discocaml> <Kali> they aren't even needed for tuples
<technomancy> companion_cube: ohhh so for tuples they're for grouping as well; interesting
<technomancy> is it valid to think of unit as an empty tuple, which is kind of just a special case of grouping nothing?
<discocaml> <Kali> in all other instances they can either be elided or replaced with `begin ... end`, `@@`, or `|>`
<discocaml> <Kali> (@@ is application and |> is reverse application)
<discocaml> <._null._> You don't need it for destructuring though ? Unless you meant multi-argument constructors as well ?
<discocaml> <Kali> destructuring *in definitions*
<discocaml> <Kali> as in
<discocaml> <Kali> `let f a,b = ...` is not allowed
<technomancy> in fennel we have parens used for two things (calling and also destructuring multiple values which are kind of like shitty tuples) and I feel like that's too much =)
<discocaml> <Kali> (instead of `f (a,b)`)
<discocaml> <._null._> I'd consider this an instance of grouping, but ok
<discocaml> <Kali> oh, i see
<discocaml> <Kali> oh, do you work on fennel? that's cool
<discocaml> <Kali> i love lua and fennel
<technomancy> glad you like it =D
xmachina has quit [Quit: WeeChat 4.0.4]
xmachina has joined #ocaml
xmachina has quit [Client Quit]
<dh`> there's also data constructor and functor arguments, if you're talking about parens in ocaml
<dh`> and yes, unit is effectively the empty tuple
<discocaml> <._null._> Those were already mentioned. You also need them around the `module` keyword
bartholin has quit [Quit: Leaving]
<dh`> didn't read carefully enough I guess
Serpent7776 has quit [Ping timeout: 255 seconds]
<companion_cube> Around `val` too, at the module/expression interface
azimut has quit [Ping timeout: 246 seconds]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
rgrinberg has joined #ocaml
dnh has quit [Ping timeout: 255 seconds]
rgrinberg has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Tuplanolla has quit [Ping timeout: 255 seconds]
yosik has quit [Ping timeout: 246 seconds]