show `else` prefix for instance chain items in docs by csicar · Pull Request #3715 · purescript/purescript · GitHub
Skip to content

show else prefix for instance chain items in docs - #3715

Open
csicar wants to merge 7 commits into
purescript:masterfrom
csicar:purescript-docs-instance-chain
Open

csicar wants to merge 7 commits into
purescript:masterfrom
csicar:purescript-docs-instance-chain

Conversation

@csicar

@csicar csicar commented Aug 9, 2019

Copy link
Copy Markdown

Fix for Issue #3605

  • test complete successfully

example:
example

Changes

  • added Bool to ChildInstance Constructor
  • added chained to JSON representation, with default value False for backwards-compatability
  • added rendering for else keyword

Notes

Displaying the instances of a type can look weird because the else prefix has no meaning there. I would suggest hiding the else keyword when displaying anywhere except a type class context
weird case

@hdgarrood

Copy link
Copy Markdown
Contributor

@csicar

csicar commented Aug 18, 2019

Copy link
Copy Markdown
Author

The solution in bc3cc4e is not very elegant, but works. Basically the problem is, that rendering of the ChildDeclaration needs to know if the parent declaration is a TypeClass.

Alternatively, I could pass the Parent declaration to Renderer.renderChildDeclaration, which might be nicer (depending on preference).

@hdgarrood

Copy link
Copy Markdown
Contributor

This is actually quite a bit more subtle than I first expected. I think what we have here is still not quite right, for a couple of reasons:

  1. It could be misleading to display an instance from a chain outside of the context of that chain. If we were to display an instance which is halfway down a chain without the instances above it in the chain, it would appear that this instance would be selected more often than it actually is.
  2. It's possible that a particular data type appears more than once in an instance chain, in which case all of the instances in that chain mentioning that type would not appear to be chained, even though they should be.

I'm trying to come up with some convincing examples. I think the correct approach here may be to represent the entire chain as a single ChildDeclaration, and to include the entire chain on the instance list of data types whenever the data type appears at least once anywhere in the chain.

@csicar
csicar force-pushed the purescript-docs-instance-chain branch from bc3cc4e to 7943881 Compare October 4, 2020 17:51
@csicar

csicar commented Oct 4, 2020 •

Copy link
Copy Markdown
Author

@csicar
csicar force-pushed the purescript-docs-instance-chain branch from c00e543 to b8805c8 Compare October 4, 2020 22:14
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

Successfully merging this pull request may close these issues.

2 participants