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

Signature members #39

Open
nilern opened this issue Jul 10, 2019 · 3 comments
Open

Signature members #39

nilern opened this issue Jul 10, 2019 · 3 comments

Comments

@nilern
Copy link

nilern commented Jul 10, 2019

It should be possible to nest signature declarations inside structures and specifications inside signatures. The OCaml Map module is just one example where this is quite natural compared to the toplevel pollution in the SML/NJ library with ORD_KEY and ORD_MAP.

Abstract signatures make module type checking undecidable, so those should not be added.

@YawarRaza7349
Copy link

When you write "abstract signatures [...] should not be added", I think you mean to ban something like:

struct
  signature I = sig type t end
  structure T = struct type t = int end
end :> sig
  signature I (* abstract signature *)
  structure T : I
end

But what if I write:

struct
  signature I = sig type t end
  structure T = struct type t = int end
end :> sig
  signature I = sig end (* signature subtyping *)
  structure T : I
end

Which seems like the same thing to me. Maybe you want to mandate that signature declarations match specifications exactly, rather than allowing subtyping. Or maybe you want to ban structure specifications in a sig from having signatures declared in the same sig. Is there a specific framework you had in mind, like from a paper, that's already dealt with this stuff?

@rossberg
Copy link
Member

Since signatures can be used in both co- and contra-variant position, allowing subtyping on signature equations would be unsound.

The closest you could do is bounded abstract signatures:

struct
  signature I = sig type t end
  structure T = struct type t = in end
end :>
sig
  signature I < sig end
  structure T : I
end

But when using this in functor parameters, that would give rise to something at least as expressive as bounded quantification as in F-omega-sub with full forall-subtyping, which we also know is undecidable.

@dmacqueen
Copy link

dmacqueen commented Feb 17, 2024 via email

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

No branches or pull requests

4 participants