Skip to content

Add annotations to Type and Kind - #3484

Merged
natefaubion merged 11 commits into
purescript:masterfrom
natefaubion:ann-types-kinds
Dec 21, 2018
Merged

Add annotations to Type and Kind#3484
natefaubion merged 11 commits into
purescript:masterfrom
natefaubion:ann-types-kinds

Conversation

@natefaubion

@natefaubion natefaubion commented Dec 15, 2018

Copy link
Copy Markdown
Contributor

This is a WIP which adds annotations to Type and Kind, and parses with SourceAnn. This is just a rough first pass which happens to compile. For the most part this is a robotic, conservative change, without any consideration to how or if we propagate source annotations to compiler generated types/kinds.

Some things that I'd like to do next:

  • Maybe have a type alias like type SourceType = Type SourceAnn
  • Have constructors pre-applied to NullSourceAnn.
  • Probably remove the Eq and Ord instances and have an "unsafe" newtype around them which ignores the annotations. I replaced all the cases of == I saw with eqType, but I'm not confident I caught them all and it very likely will break things.
  • See how we can improve type and kind errors now that we have more source information.

@garyb

garyb commented Dec 20, 2018

Copy link
Copy Markdown
Member

If the tests are passing we should probably get this in asap and work out how to make the errors better afterwards - any time I've attempted this in the past, the slightest drift in master makes keeping these kind of branches up to date agonising.

@natefaubion

natefaubion commented Dec 20, 2018

Copy link
Copy Markdown
Contributor Author

The only concern I have is around bloat of various JSON things. CoreFn doesn't emit types right now, I don't think, so it's not a problem there, but the stuff around docs/publish do. Is this something to be concerned about? Or even just leaking things like path names.

@natefaubion

Copy link
Copy Markdown
Contributor Author

Also, I kept the Eq and Ord instances, but they just ignore annotations. Removing the instances broke lots of other derived instances. While omitting them in Eq/Ord is a little dubious, it should at least be identical to the previous behavior.

@natefaubion

Copy link
Copy Markdown
Contributor Author

I've updated the Docs code to use () as the annotation, so it shouldn't leak source spans.

@natefaubion natefaubion changed the title [WIP] Add annotations to Type and Kind Add annotations to Type and Kind Dec 21, 2018
@hdgarrood

Copy link
Copy Markdown
Contributor

Will this affect the externs format?

@natefaubion

Copy link
Copy Markdown
Contributor Author

Not appreciably, but it will keep annotations on types and kinds. Do you have any specific concerns?

@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.

I agree with @garyb re getting this in asap. Here are some minor comments; other than these, I think this PR looks good.

Comment thread src/Language/PureScript/AST/SourcePos.hs Outdated
Comment thread src/Language/PureScript/Kinds.hs
Comment thread src/Language/PureScript/Kinds.hs
Comment thread src/Language/PureScript/Kinds.hs
Comment thread src/Language/PureScript/Kinds.hs
Comment thread src/Language/PureScript/Kinds.hs Outdated
Comment thread src/Language/PureScript/Kinds.hs Outdated
@hdgarrood

hdgarrood commented Dec 21, 2018

Copy link
Copy Markdown
Contributor

Re specific concerns on the externs format: not really. We don't consider the externs format part of the public interface, right? It's only meant to be for the use of the compiler? I was just wondering because pulp makes use of https://github.com/hdgarrood/purescript-externs-check, which will check whether your main looks like its type makes sense for use as an entry point.

@natefaubion

Copy link
Copy Markdown
Contributor Author

It's possible that it could affect that yes, because the codec for Type is automatically derived. For Kind, I made a point to add the annotation as an extra field, and not part of contents, which preserves compatibility.

@hdgarrood

Copy link
Copy Markdown
Contributor

Ok, great. Just to clarify I don't think the externs format issue should affect the mergeability of this PR, it's just handy to know about in advance from the point of view of pulp.

@natefaubion

Copy link
Copy Markdown
Contributor Author

I think I've addressed your comments.

@natefaubion

Copy link
Copy Markdown
Contributor Author

I created #3494 to track the specific issue with Type.

@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.

Yep, this looks good to me now! Thanks for creating that issue.

@garyb

garyb commented Dec 21, 2018

Copy link
Copy Markdown
Member

🎉

@natefaubion
natefaubion merged commit 05744cb into purescript:master Dec 21, 2018
@natefaubion
natefaubion deleted the ann-types-kinds branch December 21, 2018 17:43
@garyb garyb mentioned this pull request Jan 12, 2019
3 tasks
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.

3 participants