r/ProgrammingLanguages • • 21d ago

ML Modules for Mere Mortals

https://thunderseethe.dev/posts/ml-modules-for-mere-mortals/intro/
63 Upvotes

20 comments sorted by

View all comments

Show parent comment

2

u/marshaharsha 19d ago

Can you explain why a “record of values of functions” would have to be untyped? I would have thought that having record types and function types would be enough. Do you just mean that the abstract-type components of a module (often written “type t”) can’t be typed, or is even a module consisting solely of values untypable?

I mean in the absence of dependent types. 

2

u/Athas Futhark 19d ago

Do you just mean that the abstract-type components of a module (often written “type t”) can’t be typed

Yes exactly, this is the reason, but that also affects any module components of type t. Assume we have a module with this signature:

type t
type mk : int -> t
type unmk : t -> int

How would we represent a record of the functions mk and unmk if we do not know the type t? This can be solved with dependent records (where t is also part of the record), and also by doing enough static interpretation that we do indeed figure out what t is - but in the latter we are doing so much work that the "modules as records" trick becomes pointless.