mange has quit [Remote host closed the connection]
bartholin has joined #ocaml
<discocaml>
<doraent> This is what I think aswell, but basically everytime we need to enforce the type of something we can use a .mli file/something lighter than a module type. It really looks like a java version translated to ocaml
<discocaml>
<doraent> Sadly the maintainer does not answer any issue anymore, in fact the repo of the ocaml-version is dead (the book cannot even be built from there)
cr1901_ has joined #ocaml
cr1901 has quit [Ping timeout: 276 seconds]
bartholin has quit [Quit: Leaving]
myrkraverk has joined #ocaml
beo has joined #ocaml
Serpent7776 has joined #ocaml
zenes has quit [Ping timeout: 260 seconds]
<discocaml>
<octachron> From my memory, the main issue is that some of the later examples need higher-kinded polymorphism, which need to go through functor in OCaml. And thus the OCaml version of the book decided to use functors even for basic function composition.
Haudegen has joined #ocaml
olle has joined #ocaml
mbuf has joined #ocaml
<discocaml>
<doraent> yes but this is not only a choice, this is strictly speaking an error at some points. A good example is the very first snippet :
<discocaml>
<doraent> (G : Polymorphic_Function_G with type b = F.b) =
<discocaml>
<doraent> struct
<discocaml>
<doraent> (** OCaml doesn't have a compose operator. So, creating one. **)
<discocaml>
<doraent> let ( >> ) g f x = g (f x)
<discocaml>
<doraent> let compose : 'a -> 'c = G.g >> F.f
<discocaml>
<doraent> end
<discocaml>
<doraent> ```
<discocaml>
<doraent> here there is no need to declare 2 module types for F and G, and it does not even fit the idea of the haskell snippet.
<discocaml>
<doraent> Moreover, some parts of the book are basically haskell-focused (not only the snippets), A very easy example is the string types in Ocaml/Haskell, in Haskell String = [Char] which is not true at all in Ocaml. I am pretty sure we can find tons of other examples (i found some in the parts about recursion, which is not handled exactly in the same way in ocaml and haskell)
<discocaml>
<otini_> maybe it was translated from Haskell by someone who didn’t know or didn’t care about ocaml’s specificities?
<discocaml>
<doraent> I am pretty sure it is the case, yes (and I think the objective of this "translation" was only to give ocaml snippets, and not fully express the book idea in ocaml)
hsw has quit [Remote host closed the connection]
hsw has joined #ocaml
mbuf has quit [Quit: Leaving]
f[x] has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
myrkraverk_ has joined #ocaml
myrkraverk has quit [Read error: Connection reset by peer]
theblatte has quit [Ping timeout: 252 seconds]
theblatte has joined #ocaml
theblatte has quit [Ping timeout: 245 seconds]
theblatte has joined #ocaml
Haudegen has joined #ocaml
trillion_exabyte has quit [Ping timeout: 276 seconds]
pi3ce has quit [Read error: Connection reset by peer]
pi3ce has joined #ocaml
<discocaml>
<alyxshang> Chat can I have a hug
<discocaml>
<alyxshang> I finally understood pointers
<discocaml>
<alyxshang> I'm so happy I could cry
<discocaml>
<._null._> Thanks to OCaml ?
<discocaml>
<alyxshang> No, Ed from low-level-learniny and my old code.
<discocaml>
<alyxshang> No, Ed from low-level-learning and my old code.
<discocaml>
<alyxshang> I'm trying to keep the positive-feedback loop going.
<discocaml>
<alyxshang> For learning things about my field I have missed.
<discocaml>
<alyxshang> (That includes OCaml)
<discocaml>
<._null._> Makes more sense, but good for you. As someone who forgot why pointers are difficult, what did you not understand ?
<discocaml>
<alyxshang> I got confused between assigning a pointer to a mem location and dereferencing said pointer later on. The double use of the asterisk for either task.
<discocaml>
<alyxshang> But I got it now.
<discocaml>
<alyxshang> And that the "&" is a reference to the mem location of the created variable.
<discocaml>
<._null._> That *p behaves similarly to p[0] for arrays so ? Where you both get and set them using the "same" syntax ?
kurfen has quit [Ping timeout: 252 seconds]
kurfen has joined #ocaml
<discocaml>
<lukstafi> `[@@deriving sexp_of]` feature wish: in addition to `@opaque`, have a way to provide an alternative sexper... My workaround for a specific use case -- to break up sexping a recursive record, duplicate the record definition and in the second one use `[@@deriving sexp_of]`, for the first one manually write the sexper to output the record id.
<discocaml>
<alyxshang> Well yes, but imagine how cryptic this was for a crab when it first had some C code between its pincers.
<discocaml>
<._null._> I'm much less used to the situation in Rust, but I at least know that it's quite different
jsoo has quit [Ping timeout: 260 seconds]
<dh`>
rust reference syntax is very confusing
<companion_cube>
it's just & and * though?
<discocaml>
<cristianoc> Not sure how relevant to this discussion, just adding some detail.
<discocaml>
<cristianoc> In ReScript, currying in application is optional instead of the default. Making partial application opt-in.
<discocaml>
<cristianoc> Plus, higher-order functions are explicit about the arity, which is a real change, though in practice the difference comes up less often than one would expect.
<discocaml>
<cristianoc> (The motivation there is when interfacing with JavaScript directly one has to pay the price for the mismatch between ambiguous arity on one side and explicit arity on the other side).
<discocaml>
<doraent> Basically we should do this everywhere, and even adapt the text to make it a real "ocaml version" and not juste ocaml snippets with some Haskell text
bartholin has joined #ocaml
<dh`>
cube: rust? yes, except where it's not, and it's subtly different in places, and there are implicit conversions
<companion_cube>
I'd love to hear more, to me it's fairly straightforward
<companion_cube>
only place it's tricky is in patterns, and even then
<dh`>
I have not used it that much yet and it may just be that the intro documentation is obfuscating it
<dh`>
but there are definitely implicit conversions from scalar values to references to them
<dh`>
which C specifically doesn't allow
<companion_cube>
nope, never
<companion_cube>
all references in rust are explicit
<companion_cube>
a few _de_references are implicit in cases where it's obvious
szkl has quit [Quit: Connection closed for inactivity]
Serpent7776 has quit [Ping timeout: 252 seconds]
<dh`>
ok, maybe I'm confused
<dh`>
implicit dereferences are just as bad though
<companion_cube>
having foo.x deference when foo is a reference sounds fine to me
<companion_cube>
you don't gain much by disallowing that
<dh`>
other than keeping a strict separation of concepts
<dh`>
this is why C has ->
<companion_cube>
it's just useless to separate the two in this case
<discocaml>
<astreamingcomesacrossthesky> What are the optics on using archived libs in the OCaml-sphere? I wanna check out Bastet. Is it archived bc there's something wrong with it? Or is it merely stable and useable?
<discocaml>
<deepspacejohn> (I assume you mean the "archived" status on the GitHub repo) I don't think archiving has any implicit meaning in the OCaml ecosystem. I'm not sure about Bastet specifically.
<discocaml>
<astreamingcomesacrossthesky> Right, yeah, I do mean on GH. Good to know, thanks. I found it from a cursory search into category theory libraries but if there are others I'm glad to take recommendations. I know Base has cats stuff but I'm not sure I wanna bring in all that just for a small part of the whole.
Putonlalla has quit [Ping timeout: 260 seconds]
<discocaml>
<alyxshang> Yeah, in Rust you just have an ampersand for refs and an asterisk for dereferencing things.
<discocaml>
<alyxshang> Provided certain traits are implemented for the latter.
<companion_cube>
no new language is keeping -> as a dereference operator, fwiw
<companion_cube>
auto deref on field or method access is just the norm now
Anarchos has joined #ocaml
euphores has quit [Ping timeout: 248 seconds]
euphores has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
Haudegen has joined #ocaml
bartholin has quit [Quit: Leaving]
Haudegen has quit [Quit: No Ping reply in 180 seconds.]