Skip to content

Add named type wildcards - #3500

Merged
natefaubion merged 4 commits into
purescript:masterfrom
natefaubion:named-type-wildcards
Jan 13, 2019
Merged

Add named type wildcards#3500
natefaubion merged 4 commits into
purescript:masterfrom
natefaubion:named-type-wildcards

Conversation

@natefaubion

Copy link
Copy Markdown
Contributor

Implements #715 #1228

This is a slight UX breaking change. This adds ?foo syntax for types, which act as named wildcards which always warn. The previous _ syntax acts as a partial type signature, which does not warn unless it's part of a module-level type signature.

I didn't change the warning (WildcardInferredType) except to add the name, but maybe it warrants a separate warning.

Comment thread src/Language/PureScript/TypeChecker.hs Outdated
@natefaubion

Copy link
Copy Markdown
Contributor Author

One UX consideration is should ?foo in types emit an error rather than a warning? It's necessary for values, but not for types. If we leave it as a warning, that means you can accidentally leave ?foo in a module inadvertently since we don't persist warnings.

@LiamGoodacre

Copy link
Copy Markdown
Member

I'd prefer if both type-level and term-level holes behaved the same, so if term holes error then so should type holes.

@LiamGoodacre

Copy link
Copy Markdown
Member

To add to that - I feel like _ shouldn't ever error or warn, and ?foo should always error.
Now that we have the option to use ?foo, the intent behind using _ becomes "fill in this bit for me" instead of "help me figure this bit out".

@natefaubion

Copy link
Copy Markdown
Contributor Author

Currently we warn if you leave off a type signature for module-level declarations, which is why I preserved the _ warning there. Otherwise, foo = 42 :: _ just becomes a way to not get warnings while still leaving off signature.

@no-longer-on-githu-b

Copy link
Copy Markdown
Contributor

I'd prefer if both type-level and term-level holes behaved the same, so if term holes error then so should type holes.

And they should be called kinded holes and report only the kind. 😅

@natefaubion

Copy link
Copy Markdown
Contributor Author

This is ready for review again. I've addressed the UX concerns.

  • ?foo always raises a HoleInferredType error. When it's in a type signature, it just does not provide a TypeSearch.
  • _ does not warn, unless it's in a module-level type signature, where it continues to throw a WildcardInferredType warning.

@garyb garyb mentioned this pull request Jan 12, 2019
3 tasks

@hdgarrood hdgarrood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Both of the discussed behaviours re erroring vs warning seem sensible to me; I don't have a preference either way.

@natefaubion
natefaubion merged commit 73fee56 into purescript:master Jan 13, 2019
@natefaubion
natefaubion deleted the named-type-wildcards branch January 13, 2019 15:58
dariooddenino pushed a commit to dariooddenino/purescript that referenced this pull request Jan 18, 2019
* Add named type wildcards

* Remove debug

* Use HoleInferredType for named type wildcards
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants