adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.09 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.09/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
cantstanya has quit [Remote host closed the connection]
hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
cantstanya has joined #ocaml
hlisp has quit [Ping timeout: 264 seconds]
Haudegen has quit [Ping timeout: 258 seconds]
raver has quit [Read error: Connection reset by peer]
raver has joined #ocaml
hlisp has joined #ocaml
jao has quit [Remote host closed the connection]
hlisp has quit [Ping timeout: 256 seconds]
jao has joined #ocaml
jao has quit [Remote host closed the connection]
jao has joined #ocaml
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 240 seconds]
mbuf has joined #ocaml
wingsorc has quit [Quit: Leaving]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 260 seconds]
mfp has quit [Ping timeout: 260 seconds]
dborisog has joined #ocaml
hlisp has joined #ocaml
amiloradovsky has quit [Ping timeout: 244 seconds]
hlisp has quit [Ping timeout: 265 seconds]
porchetta has quit [Ping timeout: 246 seconds]
oturtle has quit [Ping timeout: 264 seconds]
porchetta has joined #ocaml
oturtle has joined #ocaml
wagle has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
wagle has joined #ocaml
hlisp has joined #ocaml
jao has quit [Ping timeout: 264 seconds]
hlisp has quit [Remote host closed the connection]
hlisp has joined #ocaml
narimiran has joined #ocaml
hlisp has quit [Ping timeout: 246 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 240 seconds]
hlisp has joined #ocaml
nullcone has joined #ocaml
zolk3ri has joined #ocaml
hlisp has quit [Read error: Connection timed out]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 265 seconds]
vicfred has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
vicfred has joined #ocaml
hlisp has quit [Ping timeout: 256 seconds]
sz0 has joined #ocaml
ggole has joined #ocaml
hlisp has joined #ocaml
hlisp has quit [Read error: Connection timed out]
mbuf has quit [Quit: Leaving]
tane has joined #ocaml
hlisp has joined #ocaml
Haudegen has joined #ocaml
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 260 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 246 seconds]
amiloradovsky has joined #ocaml
<Leonidas> wow, this is so good, I am grabbing popcorn: https://discuss.ocaml.org/t/lwt-is-so-useful-why-its-not-in-the-stardard-lib/5675
<Armael> idk
jbrown has joined #ocaml
<Armael> I'm not sure that it raises controversial points: yes, you need C code to do stuff that OCaml cannot do, yes you can break safety that way, but that's the same for the C code from the stdlib
<Armael> (it's also not clear what one would gain from having lwt in the stdlib)
amiloradovsky has quit [Ping timeout: 240 seconds]
tane has quit [Quit: Leaving]
sagax has quit [Read error: Connection reset by peer]
sagax has joined #ocaml
ollehar2 has joined #ocaml
<ollehar2> Correct me if i'm wrong, but it's not possible to make a functor without creating a module inside a module?
<ollehar2> because there's no way to write an mli file to tell it to accept a module?
<ollehar2> And the idiomatic way is to make a "Make" module? Like in Set,Make(Foo)?
<Armael> yes
<Leonidas> Armael: I was thinking it would be fun, since it is full of questions that are all sorta answered by "mu".
<Leonidas> it is somewhat of a strange python-centric POV to put things in the stdlib
<Leonidas> which hasn't ever even worked for them since the stdlib is where things go to die.
mfp has joined #ocaml
<Armael> ah :)
<Armael> oh, is that so @ python's stdlib? I didn't know that
<ollehar2> mu?
<ollehar2> @armael thanks
hlisp has joined #ocaml
nullcone has quit [Quit: Connection closed for inactivity]
hlisp has quit [Ping timeout: 246 seconds]
<notnotdan> Armael | (it's also not clear what one would gain from having lwt in the stdlib)
<notnotdan> I guess there are the same advantages as having a modern stdlib in general
<notnotdan> instead of having several competing "standard" libraries
mbuf has joined #ocaml
<ollehar2> So why aren't all modules in OCaml functors?
<ollehar2> If you want to "code to an interface, not an implementation", you always need a functor to inject your dependencies.
<simpson> We could imagine that unparameterized modules are like functors which take no arguments. (There is a technical and formal way to put this.)
<ollehar2> Yeah, but why is that the default?
<simpson> Historical perspectives, probably. These days, some systems *do* have this sort of thinking. The last module system I worked on had zero-or-more imports, and one export, and so every module is like a functor in that system. Curiously, the word "functor" isn't used there!
<ollehar2> Hm, which system is that? Academic?
<ollehar2> So there's no global scope, or no "import without interface"?
<simpson> I'm thinking of Monte, as usual. Indeed there's no global scope. Racket and Newspeak (in addition to OCaml, of course!) are all good languages to look at for this sort of thing. Here's an example from a recent module: https://github.com/monte-language/typhon/blob/master/mast/games/sdf.mt#L1-L8
<ollehar2> "as usual"? :D
<theblatte> ollehar2: mostly it gets incredibly verbose if you functorise everything, and very hard to understand which code ends up being called in the functor spaghetti.
<ollehar2> yeah, but your language is supposed to make that easy for you :)
<theblatte> if your functor is only ever instantiated with the one module then I prefer for it not to be a functor
<theblatte> but yeah, basically a style issue at that point
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 265 seconds]
<ollehar2> Well, also a case about making your dependencies explicit to increase testability, but yeah.
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 256 seconds]
<ollehar2> that's right, i'll go agile on yo asses
<ollehar2> someone call uncle bob
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 260 seconds]
rowbee is now known as robi
oturtle has quit [Ping timeout: 260 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 246 seconds]
oturtle has joined #ocaml
ollehar2 has quit [Quit: Connection closed]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 260 seconds]
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 260 seconds]
tane has joined #ocaml
jao has joined #ocaml
hlisp has joined #ocaml
hlisp has quit [Ping timeout: 260 seconds]
ollehar2 has joined #ocaml
<ollehar2> what's the name of the sig exported by an mli file?
<ollehar2> like, common.mli --> Common is available as sig?
<Armael> you don't get a signature, just a module with the signature as written in common.mli
<Armael> a module with its signature being what's written in common.mli *
<ollehar2> ok, so I can never use a signature from an implicit module?
<Armael> you can use "module type of Common" if you need to
<ollehar2> as argument to a functor?
<ollehar2> ok, and then I have to do `Common.COMMON`
<ollehar2> fuck sake
<Armael> what
<Armael> functors take modules as arguments, not signatures
<Armael> unless you are writing the type of a functor?
<ollehar2> module Make (Common : Common.COMMON) = ...
<Armael> you can look at how Set or Map from the stdlib do it
<ollehar2> yeah
<ollehar2> github can't search by filename. sigh.
<ollehar2> nvm, easy to find
<ollehar2> ok, so they define the internal module type as S
<ollehar2> module make (Common : Common.S) ?
<ollehar2> Common.C?
<ollehar2> map.ml also uses S, so `t` for module type, and `S` for module sig. got it.
<ollehar2> are module sigs not nominal? how come String automatically implements OrderedType?
<ollehar2> is it cast?
hlisp has joined #ocaml
<Armael> module sigs are indeed not nominal
<ollehar2> that's backwards?
ygrek has joined #ocaml
<ollehar2> if a module has type t and a function compare : t -> t -> int, it is *assumed* it's an OrderedType?
<Armael> no
<ollehar2> It should be the other way around, no? String should *tell* the environment by name, not structure, that it is OrderedType?
<Armael> it's just that if you give it to a functor that requires an OrderedType
<theblatte> it's structural typing, not nominal
<Armael> then the typesystem will check that the signature of your module includes OrderedType
<ollehar2> ok, I thought objects were the only structural types in OCaml.
<Armael> that's structural typing at the module level, not at the level of types
<ollehar2> same thing, it's interfaces "with extra steps" :)
<Armael> *shrug*
<ollehar2> what if I have a compare function that's not ordered type compliant? can I prevent it from being used in Map or Set?
<theblatte> yes, don't name it "compare" :)
<ollehar2> or don't use type t
hlisp has quit [Ping timeout: 258 seconds]
<ollehar2> one could argue that nominal typing better communicates intent, but bah
<ollehar2> structural interface typing could be interesting, I guess.
<ollehar2> it's like javascript all over again :D
<theblatte> thatsbait.jpg
<ollehar2> ^^
<ollehar2> did I mention that "blatte" is a very offensive way to say african american in Swedish?
<theblatte> no, ouch
<ollehar2> slightly distracting
<companion_cube> in french it just means "cockroach" :D
<ollehar2> hahaha
<theblatte> yes, not offensive at all :p
<ollehar2> the right wing populist "angry foreigner" had a channel in swedish before called "arg blatte"
<ollehar2> youtube channel*
<ollehar2> sorry, ot
hlisp has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
hlisp has quit [Remote host closed the connection]
NinaAgdal has joined #ocaml
hlisp has joined #ocaml
NinaAgdal has quit [Client Quit]
<ollehar2> You people also follow F*?
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml
ihavelotsoffries has joined #ocaml
hlisp has quit [Ping timeout: 260 seconds]
<ollehar2> What's my error here? https://paste.centos.org/view/fd8d72fd
<ollehar2> Error: Unbound module TAG
<ollehar2> I can't use module signature in another module signature?
bartholin has quit [Read error: Connection reset by peer]
ihavelotsoffries has quit [Quit: Connection closed]
<ollehar2> In map.mli: module Make (Ord : OrderedType) : S with type key = Ord.t
<ollehar2> You have to manually override the type?
<ollehar2> this works: module Make (Tag : TAG) : S with type tag_tbl = Tag.t
<ollehar2> hm hm
Haudegen has quit [Quit: Bin weg.]
ollehar2 has quit [Quit: Connection closed]
Haudegen has joined #ocaml
ollehar2 has joined #ocaml
<ollehar2> Question: Why does map.ml not use sig S in its implementation? https://github.com/ocaml/ocaml/blob/trunk/stdlib/map.ml#L22
<ollehar2> It's enough to define the relation between S, Make in the mli file?
<companion_cube> yes
<companion_cube> it's even just a constraint
<companion_cube> you could do without `S`, it's just there to say "I promise Map.Make returns this"
dborisog has quit [Ping timeout: 240 seconds]
<ollehar2> OK
<ollehar2> Can't solve it in my own code
<ollehar2> bbl
bartholin has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
gahr has quit [Quit: Lost terminal]
gahr has joined #ocaml
gahr has quit [Client Quit]
gahr has joined #ocaml
raver has quit [Read error: Connection reset by peer]
zmt01 has joined #ocaml
zmt00 has quit [Ping timeout: 240 seconds]
chripell_ has quit [Quit: Leaving]
amiloradovsky has joined #ocaml
narimiran has quit [Remote host closed the connection]
narimiran has joined #ocaml
raver has joined #ocaml
mbuf has quit [Quit: Leaving]
vicfred has quit [Remote host closed the connection]
amiloradovsky has quit [Ping timeout: 240 seconds]
<ollehar2> Why does map.ml repeat the sig S from map.mli?
<companion_cube> type definitions need to be in .ml too
<ollehar2> ok
<ollehar2> So in my code i get this error:
<ollehar2> Error: This expression has type Common.tag_tbl
<ollehar2> but an expression was expected of type ('a, 'b) Hashtbl.t
<ollehar2> but module Make (Tag : TAG) : S with type tag_tbl = Tag.tbl
<ollehar2> from Tag.tbl
<companion_cube> what's Tag.tbl?
<ollehar2> where TAG tbl is `type tbl = (string, t) Hashtbl.t`
<ollehar2> and t is just `type t`
<ollehar2> Full code list of common.mli: https://paste.centos.org/view/e0e124f9
<companion_cube> do you expose these type equalities in .mli files, too?
oturtle has quit [Ping timeout: 256 seconds]
<ollehar2> I think...?
<ollehar2> So Common.tag_tbl cannot be unified with ('a, 'b) Hashtbl.t?
<companion_cube> https://paste.isomorphis.me/7bV this typechecks for me
<ollehar2> let me compare with my other code
amiloradovsky has joined #ocaml
<ollehar2> Is there any docs for stuff like this? `module Make (Tag : TAG) : S with type tag_tbl = Tag.tbl =`
<ollehar2> `with` ...
<ollehar2> Are there*
<ollehar2> I get syntax error
<companion_cube> the second = is never allowed I think
<companion_cube> is my example wrong?
<ollehar2> no no, I got syntax error in my own code, sorry
oturtle has joined #ocaml
<ollehar2> maybe my dependencies are too circular
<ollehar2> sec
<ollehar2> This code list also includes deck.ml that uses common.mli: https://paste.centos.org/view/c82d33c9
<ollehar2> I'm compiling with `ocamlfind ocamlopt common.mli common.ml deck.ml`
<ollehar2> Error is as above: Error: This expression has type Common.tag_tbl
<ollehar2> but an expression was expected of type ('a, 'b) Hashtbl.t
<ollehar2> line 33
<companion_cube> hmm compile the interface first I think
<ollehar2> deck.mli? Maybe I should write it...
<companion_cube> ocamlfind opt -c common.mli
<companion_cube> I think
<companion_cube> (or, you know, just use dune)
<ollehar2> I'm not sure dune existed when I started this project ^^
<companion_cube> move to dune anyway 🤷
<companion_cube> I migrated a ton of projects from oasis to dune
<ollehar2> hm hm
<ollehar2> I can't pass a module as an argument to a sig? How do I even google that...
<companion_cube> what does it mean?
<ollehar2> module type S (Common : Common.S) = sig type namespace = S.namespace
<ollehar2> But that's when `when` get in, right?
<companion_cube> ah, `module type S = functor(Common : Common.S) -> sig … end`
<companion_cube> but… that's kind of complicated, and very rarely needed in my experience
<companion_cube> typically you'd just have a `module type S = sig … end` and bind it as the result of a functor
<ollehar2> functor? hm ok!
<ollehar2> Yeah, it compiled now! Had to redo deck.ml to look like map.ml :)
<ollehar2> with S and Make
<ollehar2> ah shit, no
<ollehar2> negative
<ollehar2> how do I do multiple `with`? `and`?
Jesin has quit [Quit: Leaving]
<ollehar2> S : with type t = T.t and type s = T.s
<ollehar2> ?
Jesin has joined #ocaml
<companion_cube> yep
<companion_cube> you can also link submodules
<companion_cube> `with type t = T.t and module M = T.Foo`
<ollehar2> ok
<ollehar2> thanks
<ollehar2> T_T
<ollehar2> module Make (Common : Common.S) (Tag Common.TAG) : S with type namespace = Common.namespace
<ollehar2> wait
<ollehar2> missing :
<ollehar2> but still:
<ollehar2> Error: Unbound module type Common.TAG
<ollehar2> Both TAG and S are part of common.mli
<ollehar2> What a nightmare
ollehar has joined #ocaml
<ollehar> test
ollehar2 has quit [Quit: Connection closed]
<ggole> Aren't you binding Common in the first argument, shadowing the one that you want?
<ollehar> ggole, in the function?
<ollehar> oh
<ggole> In the functor you pasted a fragment of
<ollehar> right
<ollehar> let me check
<ollehar> yes, you're right
<ollehar> I think my tag depends on my namespace and my namespace depends on my tag...
vicfred has joined #ocaml
pp02 has joined #ocaml
vicfred has quit [Client Quit]
<ollehar> the namespace contains all the different types of tags, each tag in a separate module, and the namespace should be available in every module
<ollehar> OK, but maybe solved by only giving the tag modules a *part* of the namespace, that's relevant for them.
<ollehar> and the tags depend on each other... OK, this is a mess.
pp02 has quit [Ping timeout: 240 seconds]
<ollehar> Or I cut the other way, with all tag defs in one module and all functions in another.
<ollehar> bah
<ollehar> sorry for thinking out load :|
<ollehar> loud*
narimiran has quit [Quit: leaving]
pp02 has joined #ocaml
ggole has quit [Quit: Leaving]
<ollehar> Guess my problems could also be solved by using objects instead of modules inside modules
pigeonv has joined #ocaml
<companion_cube> Leonidas: still maintaining the zmq bindings?
kark has joined #ocaml
ygrek has quit [Ping timeout: 256 seconds]
_whitelogger has joined #ocaml
jao is now known as Guest23450
cross has joined #ocaml
Niamkik has joined #ocaml
Niamkik is now known as Guest29625
towel has joined #ocaml
rowbee has joined #ocaml
eagleflo has joined #ocaml
kark has joined #ocaml
ollehar has quit [Quit: Leaving]
pp02 has quit [Remote host closed the connection]
pp02 has joined #ocaml
vicfred has joined #ocaml
pp02 has quit [Ping timeout: 240 seconds]
Guest23450 has quit [Remote host closed the connection]
jao has joined #ocaml
hlisp has joined #ocaml
tane has quit [Quit: Leaving]
hlisp has quit [Ping timeout: 256 seconds]
hlisp has joined #ocaml