Display kind signatures and comments in docs#4100
Display kind signatures and comments in docs#4100JordanMartinez merged 35 commits intopurescript:masterfrom JordanMartinez:fixDocsOfTypesWithKindSigs
Conversation
|
Latest changes now make I got the |
|
CI currently fails because the number of args for various |
|
I think the number of changes I have to do here show that it would be better if we had a desugar pass that moved If we did that, we might also want to merge |
|
CI still fails because there is a breaking change with the Class declarations still don't show up in the resulting output, but I thought the work I've done was good enough for some initial feedback. I've now moved the kind information into its own type called |
|
So, the final part of this PR that needs to be figured out is why the |
The temporary variants existed in case the functions were used elsewhere. I wasn't sure if changing their implementation might cause bugs elsewhere.
|
The tests pass locally. This PR is ready for review. |
| >>> filterInstances mn exps | ||
| >>> maybe id reorder exps | ||
|
|
||
| f :: Maybe [DeclarationRef] -> (Maybe Declaration, [Declaration]) -> Declaration -> (Maybe Declaration, [Declaration]) |
There was a problem hiding this comment.
I would prefer that we update isExported to handle kind declarations, rather than duplicating a slightly different version of it inline here. In general, I've found that having two slightly different versions of functions is a really good way to introduce bugs, especially as other changes go in over time. I think the best thing to do is to arrange things so that only one version of the function is necessary, but in cases where that's too difficult, then having one function which can work in both cases is still preferable to duplicating the implementation.
There was a problem hiding this comment.
Looks like isExported is only used for docs.
How about I convert my inline code into a function called filterDeclarations and remove isExported completely?
There was a problem hiding this comment.
Oh wait... Now I think I get what you're saying. My original approach is making this needlessly complicated.
There was a problem hiding this comment.
FWIW, longer term I think it would be good to remove this whole module, because it duplicates the existing logic in the desugaring pipeline for figuring out what is and isn't exported from a module. Ideally I think we would be able to reuse that logic for docs too, perhaps by looking at externs to figure out what is and isn't exported.
…z/purescript into fixDocsOfTypesWithKindSigs
|
Thanks for the direction, Harry! The latest commits show your idea works. Now, I just need to figure out how to deal with the CI currently fails with these errors |
Could you help me understand why you think this is a good idea? I'm guessing it's because things with kind Consider the ComponentSpec type from Halogen: -- I believe the kind signature for `ComponentSpec` is the following.
type ComponentSpec :: Type -> (Type -> Type) -> Type -> Row Type -> Type -> Type -> (Type -> Type) -> Type
type ComponentSpec state query action slots input output m =
{ eval :: (HalogenQ query action input) ~> (HalogenM state action slots output m)
, initialState :: input -> state
, render :: state -> HTML (ComponentSlot slots m action) action
}I believe this type should have its kind signature displayed in its docs only because of the type ComponentSpec state query action input output m =
{ eval :: (HalogenQ query action input) ~> (HalogenM state action output m)
, initialState :: input -> state
, render :: state -> HTML (ComponentSlot m action) action
}Without the kind signature, I as a hypothetical reader who is unfamiliar with this library would have to look at the usages of each type parameter in the record to figure out what its kind is. Some are pretty obvious (e.g. On another hand, this PR in its current state solves the problem of displaying kind signatures and their comments in the resulting documentation (pending discussion on whether the test for inferred kind signatures should 'pass' or not). What you've proposed above sounds like an optimization that can be built on top of the work I've done here. Assuming we do decide to implement the proposed idea above, wouldn't it make better sense to implement it in a separate PR? Correct me if I'm wrong, but wouldn't the implementation entail pattern matching on the |
I totally didn't explain my abuse of syntax, but what I meant was: omit kinds when they are Equivalently, omit kind signatures when every type parameter has kind Hopefully that makes a little more sense on the face of it. I'm not worried about confusion because, if the kind signature is missing, the arity of the type constructor is enough to reconstruct the entire kind. Maybe it should be its own PR, but I think |
|
I agree that kind signatures are probably just noise in the case where every parameter has kind |
|
As for the inferred kind signatures like |
Ah... I was confusing your idea with something else entirely. I agree with the above idea. Restating it for myself, if I have a type like the following: -- inferred kind signature
-- type Foo :: Type -> Type -> Type -> Type
type Foo a b c = Either a (Either b c)we wouldn't display the kind signature for Still, if we take this approach, we might want to update the Pursuit help pages to clarify this point. Otherwise, a reader would only know of this fact if they looked at the release notes of the PS version that would include this change.
Sounds good. |
| , declChildren = [] | ||
| , declInfo = info | ||
| , declKind = Nothing -- kind sigs are added in augment pass | ||
| , declKind = Nothing -- explicit kind signatures are added in augment pass |
There was a problem hiding this comment.
The treatment of explicit versus inferred kind signatures is irrelevant to this piece of code, so I think it shouldn’t care about the distinction - especially because when we do update this to include inferred kind signatures, it’s going to be very easy to forget to update this comment, because the code in this function isn’t going to have to change. I’d suggest leaving this comment as it was before.
There was a problem hiding this comment.
Ok. I've removed the commit that made that change.
hdgarrood
left a comment
There was a problem hiding this comment.
Looks great! Thanks for picking this up.
|
@hdgarrood Thanks! One quick question. I noticed that the changelog doesn't really explain this feature. Should I merge this as is? Or further explain what we changed here in the release notes? The current changelog just says
I was thinking of writing this:
|
|
Yeah, I think that sounds good. |
|
Huh... CI on Mac failed with this error. I'll restart the build. |

Description of the change
Fixes #3973
Remaining work
Checklist: