-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Currently, OCaml allows value expressions to "locally open" modules, but it would be helpful to extend this feature for use in type expressions.
For example, take the following code:
module Abc = struct
type a
type b
type c
end
type abc_group = (Abc.a * Abc.b * Abc.c)
I would like to be able to define abc_group
with syntax similar to this:
type abc_group = let open Abc in (a * b * c)
This would drastically reduce the verbosity of complex type signatures, especially those involving nested modules. Used in a reasonable way, this could lead to more readable code.
As for the specific syntax, I lack the experience to know what makes the most sense, so I leave that discussion to those who know more about OCaml syntax.
Edit:
@aantron proposed the following syntax:
type abc_group = Abc.(a * b * c)
This syntax is less verbose, and probably less confusing to most people.
yawaramin, TheSpyder, jfrolich, Et7f3, tsnobip and 5 more