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/
John_Ivan_ has quit [Max SendQ exceeded]
John_Ivan has quit [Ping timeout: 255 seconds]
<technomancy> https://p.hagelb.org/add.html why does this function return bool?
zbroyar_ has quit []
<technomancy> ohhhh you have to use <-; I see
<technomancy> ok! I think I got this select thing kinda sorta figured out
<technomancy> maybe I'll port this to lwt when I'm done, but it's probably a worthwhile learning exercise to do it the hard way?
arro has joined #ocaml
<technomancy> I realized I could probably get away with lwt if I installed thru apt
<technomancy> but doing that doesn't seem to work; "open Lwt" fails in the repl =\
<companion_cube> you need: `#use "topfind";;` then `"#require "lwt";;` I think
<companion_cube> things don't just load, you have to ask for them
<technomancy> huh, I read three tutorials and neither one explained that. thanks.
<companion_cube> the toplevel is generally not the most emphasized thing…
waleee has quit [Ping timeout: 252 seconds]
arro has quit [Quit: Client closed]
waleee has joined #ocaml
wingsorc has quit [Ping timeout: 252 seconds]
mima has quit [Ping timeout: 252 seconds]
waleee has quit [Ping timeout: 246 seconds]
Haudegen has joined #ocaml
bobo_ has quit [Read error: Connection reset by peer]
spip has joined #ocaml
<technomancy> is there somewhere in the docs that explain it?
<companion_cube> stuff like #require? I'm not sure
chrisz has quit [Ping timeout: 255 seconds]
chrisz has joined #ocaml
rf has quit [Remote host closed the connection]
azimut has quit [Ping timeout: 255 seconds]
<technomancy> https://p.hagelb.org/mire.ml.html OK whew! some of this code is pretty hideous, but it's more or less working, afaict
<technomancy> the thing I'm the most unhappy with is the method of putting commands in the commands hash; that should probably just be a big match instead
<technomancy> shouldn't be too hard to fix
<companion_cube> use String.split_on_char ' ' I think
<companion_cube> Str is bad™
<companion_cube> (old, full of global state)
sim642 has quit [K-Lined]
sim642 has joined #ocaml
eax_ has left #ocaml [#ocaml]
trev has joined #ocaml
dhil has joined #ocaml
Tuplanolla has joined #ocaml
mro has joined #ocaml
dhil has quit [Ping timeout: 255 seconds]
bartholin has joined #ocaml
bgs has joined #ocaml
xd1le has joined #ocaml
cedric has joined #ocaml
olle has joined #ocaml
mima has joined #ocaml
mro has quit [Remote host closed the connection]
mro has joined #ocaml
mro has quit [Ping timeout: 252 seconds]
mro has joined #ocaml
mro has quit [Ping timeout: 252 seconds]
olle has quit [Ping timeout: 260 seconds]
dnh has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 248 seconds]
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dhil has joined #ocaml
mro has joined #ocaml
trillion_exabyte has quit [Ping timeout: 246 seconds]
trillion_exabyte has joined #ocaml
olle has joined #ocaml
mro_ has joined #ocaml
mro has quit [Ping timeout: 255 seconds]
mro_ has quit [Remote host closed the connection]
mro has joined #ocaml
azimut has joined #ocaml
cedric has quit [Quit: Konversation terminated!]
dhil has quit [Ping timeout: 252 seconds]
dnh has joined #ocaml
Serpent7776 has joined #ocaml
wingsorc has joined #ocaml
mro has quit [Remote host closed the connection]
wingsorc has quit [Quit: Leaving]
wingsorc has joined #ocaml
mro has joined #ocaml
mro has quit [Remote host closed the connection]
gwizon has quit [Quit: leaving]
spip has quit [Ping timeout: 252 seconds]
bobo_ has joined #ocaml
mro has joined #ocaml
mro has quit [Ping timeout: 268 seconds]
<technomancy> oh nice; thanks
bgs has quit [Remote host closed the connection]
mro has joined #ocaml
Stumpfenstiel has joined #ocaml
rf has joined #ocaml
Serpent7776 has quit [Ping timeout: 255 seconds]
bgs has joined #ocaml
gentauro has quit [Read error: Connection reset by peer]
gentauro has joined #ocaml
mima has left #ocaml [#ocaml]
mro has quit [Remote host closed the connection]
mro has joined #ocaml
alexherbo2 has quit [Remote host closed the connection]
mro has quit [Quit: Leaving...]
arro has joined #ocaml
<arro> is there runtime overhead when using a module made from a functor (vs. manually specializing a module)?
<rf> I think (note I have limited knowledge on how functors are compiled) that they would be constructed at compile time and have limited runtime impact.
<rf> That is just a hypothesis though.
arro has quit [Quit: Client closed]
<discocaml_> <geoff> From what I understand/recall there will be some impact, since they are only compiled once (despite multiple applications) so they are using polymorphism
<discocaml_> <leviroth> Functors are not applied at compile time. You can test this by writing a functor that prints when applied.
szkl has quit [Quit: Connection closed for inactivity]
alexherbo2 has joined #ocaml
<discocaml_> <masterbuilder> that's a little surprising
azimut has quit [Ping timeout: 255 seconds]
<companion_cube> Functors might be applied at compile time and inlined. That's an optim though, it's not guaranteed.
<discocaml_> <masterbuilder> oh, kind of like devirtualization
rf has quit [Quit: Leaving]
Serpent7776 has joined #ocaml
waleee has joined #ocaml
dhil has joined #ocaml
DrakeMan has joined #ocaml
Guest88 has joined #ocaml
Guest88 has left #ocaml [#ocaml]
DrakeMan has quit [Quit: ERC 5.4 (IRC client for GNU Emacs 28.2)]
<discocaml_> <lagarto> Are side effects during functor application considered sorta a guaranteed behavior? And is there any actual use of that?
<discocaml_> <octachron> Yes. Some functors are genuinely generative.
<discocaml_> <octachron> An example would be a hashtbl functor with a random salt.
<discocaml_> <lagarto> So, for an ocaml compiler to devirtualize calls to a functor-generated module, it would have to do some analysis to prove everything is known at compile time, is that right?
<discocaml_> <octachron> Yes, but that's essentially the usual analysis for inlining.
<discocaml_> <octachron> After typing, there are no ifference left between functors/modules and functions/records.
<discocaml_> <octachron> After typing, there are no difference left between functors/modules and functions/records.
<discocaml_> <lagarto> Interesting. Is there a resource on that I can read somewhere? Do modules end up being desugared into records (full of functions?) or something like that?
<discocaml_> <lagarto> (Thanks for the answers; I've found some examples with generative functors now, but looks like I need to read more on this still ...)
<discocaml_> <octachron> The flambda manual have some amount of explanation https://v2.ocaml.org/manual/flambda.html.
<discocaml_> <lagarto> cool thanks
azimut has joined #ocaml
trev has quit [Remote host closed the connection]
bgs has quit [Remote host closed the connection]
waleee has quit [Ping timeout: 246 seconds]
waleee has joined #ocaml
vijon has joined #ocaml
dhil has quit [Ping timeout: 255 seconds]
vijon has quit [Client Quit]
alexherbo2 has quit [Remote host closed the connection]
random-jellyfish has joined #ocaml
adanwan has joined #ocaml
Serpent7776 has quit [Ping timeout: 260 seconds]
dnh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<technomancy> is there a way to curry = ?
<discocaml_> <NULL> `(=)` ?
<discocaml_> <NULL> The same way as all infix operators
<technomancy> like there doesn't seem to be a List.remove function so whatever; I can use List.filter, but having to construct a function is silly when what I really want is to curry != with the value I want to remove
<discocaml_> <NULL> Are you sure you want `(!=)` and not `(<>)`
<discocaml_> <NULL> `List.filter ((<>) e) l`
rf has joined #ocaml
<technomancy> https://p.hagelb.org/filter.html what's going on in this error message? the docs for List.filter say it takes an 'a list but the compiler says it wants a string list list list
<discocaml_> <NULL> Your arguments to `List.mem` are in the wrong order
<discocaml_> <NULL> Also, why do you use `List.cons`, why don't you use `;`s ?
<discocaml_> <NULL> And are you really sure you want to use *physical* inequality ?
waleee has quit [Ping timeout: 252 seconds]
waleee has joined #ocaml
<technomancy> wowwwwwww I got the argument order for List.mem wrong and it trickled down into the next usage of that list
<technomancy> >_<
olle has quit [Ping timeout: 255 seconds]
<rf> technomancy: That code is perfect for a result type rather than a string
<rf> You could simply return Ok () and Error ("That is not found") even option would work well.
<technomancy> hm; well in this context, this function is a command, and all the commands have to return strings that get returned to the player
<technomancy> the "OK." isn't meaningful within the program
<rf> The caller can interpret the result in anyway they see fit, and it makes your code less brittle. match get ... with Ok () -> 'OK.' | Error e -> e
<rf> It doesn't make a huge difference but I think its good practice to use monadic types for stuff like this
<technomancy> but the caller doesn't care whether the function succeeded or not
<technomancy> it just needs a string to send to the user
Tuplanolla has quit [Quit: Leaving.]
<rf> But what if Hashtbl.find fails? The program will die.
<technomancy> it's impossible to set player.room to a value which isn't present in state.rooms; there are plenty of other validity checks for that, plus it's run in a try/with
hannes has quit [Ping timeout: 252 seconds]
<technomancy> ok so my remove function compiles, but it doesn't actually do anything
<technomancy> let remove x t = List.filter (fun y -> x != y) t (* seems simple enough *)
<rf> x <> y
<rf> Will do what you want
<technomancy> wait what
<technomancy> why did that compile?
<technomancy> ugh
<technomancy> =(
<technomancy> feel like I'm back in scheme again
<technomancy> oh well, thanks for pointing out the footgun
<rf> use = and <> not != and ==
bartholin has quit [Quit: Leaving]
<technomancy> so there's no way to curry an operator then?