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

Make #show_type more useful for open variants #6555

Closed
vicuna opened this issue Sep 11, 2014 · 1 comment
Closed

Make #show_type more useful for open variants #6555

vicuna opened this issue Sep 11, 2014 · 1 comment

Comments

@vicuna
Copy link

vicuna commented Sep 11, 2014

Original bug ID: 6555
Reporter: kaustuv
Assigned to: @lpw25
Status: resolved (set by @lpw25 on 2016-12-12T16:38:39Z)
Resolution: won't fix
Priority: normal
Severity: feature
Version: 4.02.0+beta1 / +rc1
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @hcarty

Bug description

This is not particularly useful:

% ocaml
OCaml version 4.02.0

type t = .. ;;

type t = ..

type t += A | B ;;

type t += A | B

#show_type t ;;

type t = ..

It would be more useful as a way to find out what constructor names I have "used up" if all the known constructors for an open variant were shown as well.

This is especially problematic since there is not even a warning currently for:

type t = ..
type t += A
let is_a = function A -> true | _ -> false
(* ... )
type t += A
(
... )
let unexpected = is_a A (
unexpected = false *)

The user has to be extra vigilant not to accidentally reuse a constructor and get apparently nonsensical results.

@vicuna
Copy link
Author

vicuna commented Dec 12, 2016

Comment author: @lpw25

It is not clear to me that anything more useful can be done here. You can't really print all the existing constructors of a variant, and even printing only those available in scope would involve a deep search through the entire environment. You could only include those defined at the top-level, but that does not seem particularly useful to me.

It is also not really any different from the fact that the REPL lets you shadow modules, types, etc. which can result in confusion.

One thing that would be useful would be a #show_extension Foo directive (which I'm surprised doesn't already exist) and corresponding support in #show.

This is especially problematic since there is not even a warning currently for ...

This gives an error since 4.03, although obviously not in the REPL.

I'm going to mark this issue as "won't fix", but I won't close it yet to give people a chance to disagree.

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