2026/02/25

Newest at the top

2026-02-25 19:19:55 +0100 <ski> here's one SML example (from lambdaProlog implementation Terzo) :
2026-02-25 19:17:53 +0100 <EvanR> er Set
2026-02-25 19:17:39 +0100 <EvanR> Set.S
2026-02-25 19:17:36 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) (Ping timeout: 246 seconds)
2026-02-25 19:17:14 +0100 <ski> yes
2026-02-25 19:17:10 +0100 <EvanR> ok elt is in the resulting module
2026-02-25 19:17:00 +0100 <ski> (otherwise, you would know nothing about `elt', except, perhaps, that it has a `compare' function (or any function defined in terms of that), assuming the result module exports that operation)
2026-02-25 19:16:07 +0100 <ski> and the `with type elt = Ord.t' ensures that it is known to callers of `Make' that the type `elt' in the resulting module will be equal to the type `t' in the parameter module
2026-02-25 19:15:18 +0100 <ski> given a parameter module `Ord', of signature `OrderedType' (equal to `sig type t val compare : t -> t -> int'), it constructs a module of signature `S' (including a type `elt' of set elements, a type `t' of sets, and various operations on sets)
2026-02-25 19:14:54 +0100 <EvanR> so elt is defined in ...
2026-02-25 19:13:39 +0100 <ski> is one example, from OCaml, <https://ocaml.org/manual/5.4/api/Set.S.html>
2026-02-25 19:13:25 +0100 <ski> module Set.Make : functor (Ord : OrderedType) -> S with type elt = Ord.t
2026-02-25 19:12:58 +0100merijn(~merijn@host-cl.cgnat-g.v4.dfn.nl) merijn
2026-02-25 19:12:02 +0100ChanServ+v yahb2
2026-02-25 19:12:02 +0100yahb2(~yahb2@user/tomsmeding/bot/yahb2) yahb2
2026-02-25 19:11:39 +0100yahb2(~yahb2@user/tomsmeding/bot/yahb2) (Server closed connection)
2026-02-25 19:09:22 +0100 <__monty__> Backpack was sold to me as bringing ML's functors to Haskell.
2026-02-25 19:09:08 +0100ljdarj(~Thunderbi@user/ljdarj) ljdarj
2026-02-25 19:07:44 +0100wickedjargon(~user@208.98.208.115)
2026-02-25 19:07:18 +0100 <EvanR> what's an example of a sharing constraint
2026-02-25 19:07:15 +0100 <ski> yea
2026-02-25 19:05:20 +0100 <EvanR> so much stuff boils down to the management of scopes
2026-02-25 19:04:59 +0100 <ski> (iirc, you can also add sharing constraints for whole submodules)
2026-02-25 19:04:07 +0100 <ski> yes
2026-02-25 19:03:55 +0100 <EvanR> ah you called it
2026-02-25 19:03:36 +0100 <ski> (imagine there's a whole bunch of different abstract types, and one `t' is in a nested submodule, and perhaps the other one as well, and you'd like to not disturb all this structure, while still ensuring the two `t's are known to be equal)
2026-02-25 19:03:24 +0100 <EvanR> make that forall
2026-02-25 19:03:17 +0100 <EvanR> xD
2026-02-25 19:03:16 +0100 <EvanR> myFunctor :: exists t . Sig1 t -> Sig2 t
2026-02-25 19:02:35 +0100 <ski> with `myFunctor :: (exists t. ..t..) -> (exists t. ..t..)', how would you ensure the two `t's are the same, *apart* from rewriting to `myFunctor :: forall t. (..t.. -> ..t..)' ?
2026-02-25 19:02:20 +0100 <EvanR> unfortunate past tense did backpack have this "functor" feature?
2026-02-25 19:01:23 +0100 <ski> .. i'm not sure how easy it would be do express something like that, with the "module with abstract data type(s), as existentially quantified record" idiom for simulating modules, in e.g. Haskell
2026-02-25 18:59:38 +0100 <ski> standard module system stuff you do in the ML module system
2026-02-25 18:59:14 +0100 <ski> i mean so that you can specify a functor (module function), that takes a module (with a type inside), and returns another module, with a `sharing' constraint saying that the type exported by the resulting module is the same as the type in the parameter module, so that other code can use values of one type where values of the other are expected
2026-02-25 18:57:42 +0100 <EvanR> I know you don't mean that, but that's pretty common
2026-02-25 18:57:27 +0100 <EvanR> you mean inner class?
2026-02-25 18:57:11 +0100 <ski> (.. i'm not too sure how common it is to be able to define (e.g. abstract) data types inside an object, with OOP, though .. which routinely happens, with modules)
2026-02-25 18:56:15 +0100 <EvanR> it fills the same blank... single term dot stuff, which people like to latch their IDE features onto
2026-02-25 18:54:59 +0100 <ski> (e.g. in OCaml, and Alice ML)
2026-02-25 18:54:17 +0100 <ski> (typically module system have static, compile-time, resolvers. sometimes you can pass around modules at run-time, though, blurring the line a bit)
2026-02-25 18:53:00 +0100 <ski> well .. this is module system dot, not quite the same thing ?
2026-02-25 18:52:26 +0100v0id_7(~v0id_7@user/v0id-7:62772) v0id_7
2026-02-25 18:52:25 +0100 <EvanR> the power of the OOP dot
2026-02-25 18:51:53 +0100 <ski> how do you mean, ijouw ?
2026-02-25 18:51:36 +0100 <ski> (oh, and iirc, with breakpoints in GHCi, you can access them, if you break inside such a scope)
2026-02-25 18:51:25 +0100 <haskellbridge> <ijouw> can you do that top level?
2026-02-25 18:50:42 +0100 <ski> EvanR : mm, yep. i recall pondering a type system that would let you access them, from an interactor / debugger
2026-02-25 18:49:41 +0100 <ski> (iow, this is a shorter way to say `let open M in ...')
2026-02-25 18:49:12 +0100euphores(~SASL_euph@user/euphores) (Quit: Leaving.)
2026-02-25 18:49:00 +0100 <ski> __monty__ : reminds me that in OCaml, you can not only do `M.f x (M.g y z)', but you can also say `M.(f x (g y z))', where for `M.(...)', the identifiers exported by `M' are all in scope directly in the expression `...'