Replies: 2 comments 4 replies
-
tir. 1. aug. 2023 kl. 14.06 skrev Yoav Grimland ***@***.***>:
Hello! Obligatory section about me enjoying using the language aside, I'm
currently suffering two pain points with Futhark, being:
- Parametric modules cannot take non-modules as input,
What is a "non-module"? Are you suggesting that it should be possible to
parameterise a module over a type spec or a value dec, as is possible in
Standard ML via a derived form?
- and that module types cannot include declarations in them (defs).
OCaml supports so-called "value abbreviations", which turn out useful for
optimisation purposes by allowing a module to inline such abbreviations;
they are less useful in a language implementation that does module
inlining...
… Whilst I do understand Futhark attempts to be a relatively simple language
that is less oriented towards this I feel like by including a module
system, it should at least be relatively competent at expressing such
things, even perhaps at some cost to the module type system.
I do understand that due to wanting to eliminate all modules in
compile-time, unifying modules with the rest of the type-system likely
won't work, but it seems to me that this can be done, even in a somewhat
limited form whilst keeping this property (although of course, ditching the
property and using inlining to optimize away modules some of the time seems
fine).
Therefore, has this been considered before, perhaps with some kind of
unification with record types?
—
Reply to this email directly, view it on GitHub
<#2001>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAI5DO5CGKOLV7ADXJWMXO3XTDWNDANCNFSM6AAAAAA27U7SEU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Depending on exactly what you want (could you give an example?), this could be addressed using fairly simple syntactic sugar, as Martin mentions is actually possible in Standard ML. I'm a bit reluctant to add sugar that blurs the module/term division, because I find that the module language is already difficult to understand for programmers that do not have extensive Standard ML experience (there are a few of these, sadly).
I think I have an idea of what you mean, and I remember disliking the SML module system for similar reasons, but I eventually realised that it's a very crucial property of module types that they cannot contain definitions, as they must be entirely structural. It's not clear what definitions in a structural module type would mean. I think that in most cases where you might want definitions in module types, what you actually want is a bunch of "default functions" that are defined in terms of the functions declared in the module type. That may be possible to do, but you can already do something very similar yourself through liberal use of parameterised modules. I am still reluctant to add features to the module sublanguage unless there is strong evidence it's a good idea, because it's already an alien part of the language, and I suspect many of the problems with it can be solved through documentation. After all, it's difficult to say whether the module sublanguage is bad when its users have so little experience with it (and no good learning resources for becoming better at using it). So as far as I am concerned, I would prefer to study some concrete examples of pain points and figure out whether they can be solved within the existing module sublanguage, if only we had any documentation worthy of the name that actually discussed how to do so. |
Beta Was this translation helpful? Give feedback.
-
Hello! Obligatory section about me enjoying using the language aside, I'm currently suffering two pain points with Futhark, being:
def
s).Whilst I do understand Futhark attempts to be a relatively simple language that is less oriented towards this I feel like by including a module system, it should at least be relatively competent at expressing such things, even perhaps at some cost to the module type system.
I do understand that due to wanting to eliminate all modules in compile-time, unifying modules with the rest of the type-system likely won't work, but it seems to me that this can be done, even in a somewhat limited form whilst keeping this property (although of course, ditching the property and using inlining to optimize away modules some of the time seems fine).
Therefore, has this been considered before, perhaps with some kind of unification with record types?
Beta Was this translation helpful? Give feedback.
All reactions