Add more CycleInDeclaration examples#333
Add more CycleInDeclaration examples#333milesfrain wants to merge 1 commit intopurescript:masterfrom
Conversation
| Type class instance for recursive data type: | ||
| ```purs | ||
| data Chain a | ||
| = End a | ||
| | Link a (Chain a) | ||
|
|
||
| derive instance genericChain :: Generic (Chain a) _ | ||
|
|
||
| -- This builds, but blows-up call stack and triggers a | ||
| -- "too much recursion error". | ||
| instance showChain :: Show a => Show (Chain a) where | ||
| show = genericShow | ||
| {- | ||
| Fix the issue by replacing the above line with: | ||
| show c = genericShow c | ||
| -} | ||
| ``` | ||
| https://try.purescript.org/?gist=32b78ce065d60427620cdd8d40777a1f |
There was a problem hiding this comment.
Perhaps this could just be a link to the contents being added in #338?
| ### Additional Examples | ||
|
|
||
| Mutually recursive functions: |
There was a problem hiding this comment.
If we move the generic deriving example to be a link then we can change this header to be ### Mutual recursion and just focus on this mutual recursion example. I think that fits better with how other errors use the Notes section.
Also, what do you think of trimming the example a little bit to something like this?
isEven :: Int -> Boolean
isEven n
| n == 0 = true
| otherwise = again (n - 1)
again :: Int -> Boolean
again = isEvenwhich also fails, producing this error:
The value of isEven is undefined here, so this reference is not allowed.
while checking that expression isEven
has type Int -> Boolean
in binding group isEven, again
|
This PR hasn't been merged because while this is about the CycleInDeclaration, it's really explaining places where eta-expansion is needed. However, it doesn't clarify why. So, I feel like it's incomplete. |
I found the
x = xexample a bit too minimal to figure out what's required to fix these errors.