companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 5.2.0 released: https://ocaml.org/releases/5.2.0 | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
jabuxas has quit [Quit: oops :p]
jabuxas has joined #ocaml
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #ocaml
jabuxas has quit [Read error: Connection reset by peer]
jabuxas_ has joined #ocaml
jabuxas_ has quit [Quit: oops :p]
waleee has quit [Ping timeout: 252 seconds]
ansiwen_ has quit [Quit: ZNC 1.7.1 - https://znc.in]
ansiwen has joined #ocaml
mbuf has joined #ocaml
mbuf has quit [Ping timeout: 260 seconds]
mbuf has joined #ocaml
patrick has quit [Killed (calcium.libera.chat (Nickname regained by services))]
patrick_ has joined #ocaml
cr1901_ has joined #ocaml
cr1901 has quit [Ping timeout: 272 seconds]
gooby323 has joined #ocaml
mpu has joined #ocaml
Serpent7776 has joined #ocaml
gooby323 has quit [Ping timeout: 256 seconds]
myrkraverk_ has joined #ocaml
myrkraverk has quit [Ping timeout: 240 seconds]
gooby323 has joined #ocaml
wingsorc has quit [Ping timeout: 240 seconds]
bartholin has joined #ocaml
gooby323 has quit [Ping timeout: 255 seconds]
gooby323 has joined #ocaml
anpad has quit [Quit: ZNC 1.8.2 - https://znc.in]
<discocaml> <drupyog> `String.split '/'` ? :p
<discocaml> <drupyog> `String.split_on_char '/'` ? :p
anpad has joined #ocaml
gooby323 has quit [Ping timeout: 264 seconds]
<companion_cube> Then you have to remove the empty path elements :s
<discocaml> <limp.biskit> what i landed up doing haha
<discocaml> <drupyog> It's the spec-correct thing to do anyway
<discocaml> <limp.biskit> companion_cube: List.filter ((<>) "") (String.split_on_char '/' path)
jabuxas has joined #ocaml
rwmjones has quit [Ping timeout: 256 seconds]
jabuxas has quit [Ping timeout: 256 seconds]
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
<companion_cube> also don't forget to handle `/./` and `/../`
<discocaml> <limp.biskit> companion_cube: this is in a web server
<companion_cube> fair enough, but in the general case these exist
<companion_cube> file:/// and so on
<discocaml> <limp.biskit> true
waleee has joined #ocaml
<discocaml> <limp.biskit> handling them in the context of http would just introduce opportunities for request smuggling weirdness
jabuxas has joined #ocaml
jabuxas has quit [Client Quit]
Tuplanolla has joined #ocaml
rwmjones has joined #ocaml
Serpent7776 has quit [Ping timeout: 255 seconds]
mbuf has quit [Quit: Leaving]
waleee has quit [Ping timeout: 272 seconds]
waleee has joined #ocaml
waleee has quit [Ping timeout: 268 seconds]
average has joined #ocaml
waleee has joined #ocaml
Serpent7776 has joined #ocaml
trillion_exabyte has quit [Ping timeout: 268 seconds]
trillion_exabyte has joined #ocaml
average has quit [Quit: Connection closed for inactivity]
anadon has left #ocaml [#ocaml]
<discocaml> <limp.biskit> what are the best resources on modules? should i go through the chapter in ocaml: correct + efficient + beautiful
<discocaml> <limp.biskit> i’ve mostly been learning through practice, but i think i need a proper general overview of modular programming
Serpent7776 has quit [Ping timeout: 252 seconds]
trillion_exabyte has quit [Ping timeout: 256 seconds]
trillion_exabyte has joined #ocaml
<discocaml> <lukstafi> Us old-schoolers learned from this book https://caml.inria.fr/pub/docs/oreilly-book/ while it was French-only (with a dictionary on the side)
<discocaml> <limp.biskit> get to learn a language at the same time
<discocaml> <lukstafi> "This appendix describes briefly the new features offered in the current version of Objective CAML at the time of this writing, that is. Objective CAML 3.04."
<discocaml> <limp.biskit> the old logo is adorable
<discocaml> <Kali> to be honest, i just read the manual
<discocaml> <Kali> it's not too bad, and it's hard to get a more thorough covering of them
<discocaml> <lukstafi> It's not pure reference manual, it has some tutorial sections.
bartholin has quit [Quit: Leaving]
Tuplanolla has quit [Quit: Leaving.]
<discocaml> <barconstruction> Not necessarily the most accessible recommendation but there's a textbook by Benjamin Pierce on advanced topics in programming language theory where he talks about the design of module systems
<discocaml> <barconstruction>
<discocaml> <barconstruction> There is a survey by Derek dreyer of the design space in this area too
<discocaml> <barconstruction> You can also look at the paper by Appel and others which suggests a module system for Java, criticizing Java packages as being insufficient
<discocaml> <barconstruction> But I'd like to hear if you find anything good and readable on modular programming
<discocaml> <yawaramin> RWO has a good treatment of modules
<discocaml> <limp.biskit> a thing i’m finding is that subconsciously i translate a lot of concepts into their OOP equivalent, which i feel is probably going to limit my ability to actually design around modules
<discocaml> <limp.biskit> if that makes sense
<discocaml> <barconstruction> To me the main ideas of the ML module system are
<discocaml> <barconstruction> - implementor-side abstraction, I.e. encapsulation. At the point of implementation, the implementor can control the way the entire rest of the program interacts with the contents of the module. This corresponds to public/private/protected in Java. Furthermore, modules can be nested hierarchically in a tree structure and modules can expose varying amounts of functionality to other modules depending on how far apart they are on the tree
<discocaml> <barconstruction>
<discocaml> <barconstruction> the flip side of the coin is client side abstraction, the ability of the client to write code which is generic with respect to an interface. This corresponds to Java interfaces or Haskell typeclasses
<discocaml> <barconstruction> Good non-oop examples of modules are modules with multiple important types like the key and value type for a data dictionary. Dually, on the client side, Java interfaces are limited by the fact that it's awkward to write interfaces for modules multiple types.
<discocaml> <barconstruction> Or you could try writing module with two nested submodules which talk to each other but expose very limited functionality / are not visible at all outside the parent module.
<discocaml> <barconstruction> Also like some distinctions are pretty obvious like the fact that modules are namespaces, so you'll naturally want to collect things with similar functionality together in a module even if the module gets huge. Java classes are not supposed to be more than a few hundred lines and subclasses are uncommon
<companion_cube> Good stuff is, you can also use classes in ocaml!
<discocaml> <limp.biskit> ruby has the term ‘god class’ for a behemoth that’s taken on 700 methods for no good reason
<discocaml> <limp.biskit> ocaml doesn’t seem to have the same problem with modules, partially i think cause it’s easier to write a module with more functionality that’s still got a nice logical separation than in a class where your methods and state are generally bundled
<discocaml> <limp.biskit> ive been trying to avoid classes atm to force me to utilise modules well
<discocaml> <limp.biskit> i think that’s resulted in better code than otherwise, even if it’s going outside of my comfort zone
<discocaml> <limp.biskit> a side effect of that i’ve noticed is that functors sort of spread everywhere through my code in a way that wouldn’t happen under dynamic dispatch
<companion_cube> I'd say modules are good for structuring the code, anyway; classes are good for late-bound interfaces (eg IO channels)
<companion_cube> Functors, imho, are best kept small and contained
<companion_cube> Else they do contaminate a lot of the codebase
<discocaml> <limp.biskit> basically a ‘god functor’
<discocaml> <limp.biskit> what i find is that i’m able to keep the functors themselves fairly small or split into multiple “traits”, but then the amount of code i’m able to actually write without relying on one is basically nil
wingsorc has joined #ocaml