companion_cube changed the topic of #ocaml to: Discussion about the OCaml programming language | http://www.ocaml.org | OCaml 4.14.0 released: https://ocaml.org/releases/4.14.0.html | Try OCaml in your browser: https://try.ocamlpro.com | Public channel logs at https://libera.irclog.whitequark.org/ocaml/
Haudegen has quit [Ping timeout: 252 seconds]
olle has quit [Ping timeout: 248 seconds]
troydm has quit [Ping timeout: 260 seconds]
rgrinberg has joined #ocaml
azimut has quit [Remote host closed the connection]
azimut has joined #ocaml
<discocaml> <MasterBuilder> can somebody explain why http://dev.realworldocaml.org/files-modules-and-programs.html#nested-modules here `Username.t` and `Hostname.t` are distinct types? I suppose it has something to do with the fact that `t` is not concrete in the signature, but I still don't understand why they are distinct
<discocaml> <ilo Kali> `Username.t` and `Hostname.t` are both abstract types, so even if their concrete type is the same, they are not the same type *outside* of the module
<discocaml> <ilo Kali> this allows the user of these modules to never have to worry about the underlying implementation of that type—even if it changes drastically internally, it's still the same type to them externally
chrisz has quit [Ping timeout: 268 seconds]
chrisz has joined #ocaml
<discocaml> <ilo Kali> Consider this snippet given in the section:
<discocaml> <ilo Kali> ```ocaml
<discocaml> <ilo Kali> module type ID = sig
<discocaml> <ilo Kali> type t
<discocaml> <ilo Kali> val of_string : string -> t
<discocaml> <ilo Kali> val to_string : t -> string
<discocaml> <ilo Kali> val ( = ) : t -> t -> bool
<discocaml> <ilo Kali> end
<discocaml> <ilo Kali> ```
<discocaml> <ilo Kali> This implies that for all modules that satisfy this signature, there exists a type `t` in them that satisfies those functions' type signatures: it doesn't matter what the actual type `t` is, as long as the signature holds.
<discocaml> <ilo Kali> because `t` could be any type, it must be abstract
<discocaml> <ilo Kali> and abstract types are not equivalent, even if the internal type is
<discocaml> <MasterBuilder> Okay, cool, got it, I was a bit tripped up by the comparison failing, although I was aware the type was not visible outside the module
<discocaml> <MasterBuilder> thanks 🙂
<discocaml> <ilo Kali> however, you can actually "enrich" the module's signatures to make the underlying type accessible to the outside world, if you wanted to
<discocaml> <MasterBuilder> to continue with the string example, is it possible to create a new module with the module type of `String` but with the type of `t` abstract?
<discocaml> <MasterBuilder> could I bother you to show what that looks like?
<discocaml> <ilo Kali> <continuation of my message, for irc users> if you change the following lines
<discocaml> <ilo Kali> ```ocaml
<discocaml> <ilo Kali> module Username : ID = String_id
<discocaml> <ilo Kali> module Hostname : ID = String_id
<discocaml> <ilo Kali> ```
<discocaml> <ilo Kali> to
<discocaml> <ilo Kali> ```ocaml
<discocaml> <ilo Kali> module Username : (ID with type t = string) = String_id (* parentheses unnecessary but added for clarity *)
<discocaml> <ilo Kali> module Hostname : (ID with type t = string) = String_id
<discocaml> <ilo Kali> ```
<discocaml> <ilo Kali> they do become comparable
<discocaml> <MasterBuilder> I see
<discocaml> <ilo Kali> if there are multiple abstract types you wish to expose, you can use `and type ... = ...` to specify those ones, too
<discocaml> <MasterBuilder> got it
<discocaml> <MasterBuilder> and can you do the opposite? Like (pseudocode) `... with type t ...`
<discocaml> <MasterBuilder> making it abstract
<discocaml> <ilo Kali> hm, i am not sure. someone else will have to answer that
terrorjack has quit [Quit: The Lounge - https://thelounge.chat]
terrorjack has joined #ocaml
azimut_ has joined #ocaml
azimut has quit [Ping timeout: 255 seconds]
m5zs7k has quit [Ping timeout: 268 seconds]
m5zs7k has joined #ocaml
m5zs7k has quit [Ping timeout: 252 seconds]
m5zs7k has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
troydm has joined #ocaml
bgs has joined #ocaml
Haudegen has joined #ocaml
jao has quit [Ping timeout: 255 seconds]
jlrnick has joined #ocaml
jlrnick has quit [Remote host closed the connection]
Serpent7776 has joined #ocaml
bgs has quit [Remote host closed the connection]
random-jellyfish has quit [Quit: Client closed]
bartholin has joined #ocaml
bartholin has quit [Remote host closed the connection]
bartholin has joined #ocaml
trev_ has joined #ocaml
olle has joined #ocaml
bartholin has quit [Quit: Leaving]
proportions has joined #ocaml
<discocaml> <octachron> It is indeed not possible to make a type declaration in a specification (aka a module type) abstract.
azimut_ has quit [Ping timeout: 255 seconds]
waleee has quit [Ping timeout: 248 seconds]
wingsorc has quit [Ping timeout: 252 seconds]
troydm has quit [Ping timeout: 260 seconds]
<proportions> do you know who is ocaml developer
<proportions> "the french" hahhaah
<proportions> now ban me for dehumanizing you and them xaxaxa
jlrnick has joined #ocaml
jlrnick has quit [Ping timeout: 252 seconds]
azimut has joined #ocaml
proportions has quit [Remote host closed the connection]
proportions has joined #ocaml
<olle> xaxa?
<olle> You must be greek :d
<proportions> No, but "xaxa" is better than "haha" and "und" is better than "and"
azimut has quit [Quit: ZNC - https://znc.in]
azimut has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
gentauro_ has quit [Read error: Connection reset by peer]
proportions has quit [Remote host closed the connection]
gentauro has joined #ocaml
jlrnick has joined #ocaml
olle has quit [Ping timeout: 252 seconds]
proportions has joined #ocaml
bartholin has joined #ocaml
jao has joined #ocaml
Haudegen has joined #ocaml
olle has joined #ocaml
chrisz has quit [Ping timeout: 252 seconds]
jao has quit [Ping timeout: 252 seconds]
chrisz has joined #ocaml
proportions is now known as tsns
rgrinberg has joined #ocaml
tsns has quit [Remote host closed the connection]
azimut has quit [Ping timeout: 255 seconds]
jao has joined #ocaml
kakadu has quit [Quit: Konversation terminated!]
motherfsck has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Haudegen has quit [Quit: Bin weg.]
bgs has joined #ocaml
gareppa has joined #ocaml
gareppa has quit [Remote host closed the connection]
olle has quit [Ping timeout: 252 seconds]
Serpent7776 has quit [Ping timeout: 248 seconds]
szkl has quit [Quit: Connection closed for inactivity]
Haudegen has joined #ocaml
jlrnick has quit [Ping timeout: 252 seconds]
trev_ has quit [Remote host closed the connection]
hannes has quit [Read error: Connection reset by peer]
hannes has joined #ocaml
olle has joined #ocaml
trev_ has joined #ocaml
trev_ has quit [Remote host closed the connection]
tsns has joined #ocaml
tsns is now known as proportions
proportions is now known as tsns
jlrnick has joined #ocaml
trev_ has joined #ocaml
trev_ has quit [Remote host closed the connection]
trev_ has joined #ocaml
<olle> Hmm not sure what's the best place to put memory allocation strategy in the ast - variable or type?
<olle> I wanted to allow things like `point = /** @mem stack */ new Point()`
<olle> Ah I can ask the proglang discord perhaps
Tuplanolla has joined #ocaml
bgs has quit [Remote host closed the connection]
trev_ has quit [Remote host closed the connection]
cedric has joined #ocaml
gwizon has joined #ocaml
jlrnick has quit [Ping timeout: 260 seconds]
tsns has quit [Remote host closed the connection]
tsns has joined #ocaml
cedric has quit [Quit: Konversation terminated!]
azimut has joined #ocaml
olle has quit [Ping timeout: 260 seconds]
keyboard has joined #ocaml
wingsorc has joined #ocaml
bartholin has quit [Quit: Leaving]
rgrinberg has joined #ocaml
rgrinberg has quit [Client Quit]
rgrinberg has joined #ocaml
rgrinberg has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Haudegen has quit [Ping timeout: 252 seconds]
azimut has quit [Ping timeout: 255 seconds]
azimut has joined #ocaml