| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| 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?
Sorry, something went wrong.
| ### 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
Sorry, something went wrong.
|
This PR hasn't been merged because I'm not sure that should be in the Getting Started section if it's in reference to the Book. Shouldn't the Book clarify that instead? (wrong PR) 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. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
I found the x = x example a bit too minimal to figure out what's required to fix these errors.