Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programming to an interface/signature and default implementations in modules #90

Open
j14159 opened this issue Jan 8, 2017 · 3 comments

Comments

@j14159
Copy link
Collaborator

j14159 commented Jan 8, 2017

This issue is for a discussion and collection of ideas at least related to modules and signatures.

In issue #87 the distinction between OCaml's open and include came up and how the former exposes the imported module's functions in the module doing the opening. Copied from that issue:

My basic opinion right now: I see value in default implementations of signatures/interfaces but would like to consider more specificity than open appears to provide. Thoughts? Links to papers most definitely appreciated :D

@OvermindDL1
Copy link

OvermindDL1 commented Jan 8, 2017

My basic opinion right now: I see value in default implementations of signatures/interfaces but would like to consider more specificity than open appears to provide. Thoughts? Links to papers most definitely appreciated :D

There was talk in the OCaml area somewhat recently about the same but they'd not settled on a syntax, however it would be very nice to have. The suggestions that I remember were something like:

open Module.Name.[fun1; fun2]
open Module.Name.{fun1, fun2}
open Module.Name.(fun1, fun2)
open (fun1, fun2) from Module.Name (* This one was shut down fast due to parser concerns at the time *)
open fun1, fun2 from Module.Name (* This one was shut down fast due to parser concerns at the time *)
(* And a few others that I do not recall off hand, similar with import too *)

The main boon of include was being able to override prior defined functions in your own file though, adding in let rec with let being nonrec by default would allow for that.

@j14159
Copy link
Collaborator Author

j14159 commented Jan 12, 2017

Something like open module.[fun1, fun2/arity] is quite consistent with the existing function import syntax for sure and I do see the advantage in being able to pull in default implementations. I'm not sure about things "opened" overriding the definitions in the module though - that seems sort of backwards to me but I might be thinking about this wrong.

A couple of things off the top of my head:

  • minor but maybe a different word than open, like adopt or inherit to clearly show that we're making these functions part of the module pulling them in?
  • not completely thought through yet but this feels like we're going to need an actual module type and system here and probably signatures/interfaces. Any particular thoughts on this? Favourite papers or implementations?

@OvermindDL1
Copy link

I'd always be a fan of bringing in OCaml's module system whole-sale (and its implicit modules PR too).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants