Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more CycleInDeclaration examples #333

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

milesfrain
Copy link
Contributor

I found the x = x example a bit too minimal to figure out what's required to fix these errors.

Comment on lines +66 to +83
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this could just be a link to the contents being added in #338?

Comment on lines +43 to +45
### Additional Examples

Mutually recursive functions:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = isEven

which 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

@JordanMartinez
Copy link
Contributor

JordanMartinez commented Dec 18, 2022

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.

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.

3 participants