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

Improve error message for generic method implementation in point-free style for recursive type #4505

Open
yaitskov opened this issue Sep 18, 2023 · 1 comment

Comments

@yaitskov
Copy link

Description

Type checker produces non self-explanatory error in case of method instance is expressed through generic method in point-free style. My first thought was that generic function doesn't support recursive types, which is not the case and the type error is easily fixable by defining lazy argument.

To Reproduce

import Data.Generic.Rep (class Generic)
import Data.Show.Generic (genericShow)
import Prelude

data T  = A Int  | B Int T 
derive instance Generic T _
instance showT :: Show T where
  show = genericShow 

Error:

The value of showT is undefined here, so this reference is not allowed.
PureScript(CycleInDeclaration)

Expected behavior

An ideal solution is to accept point free style as

instance showT :: Show T where
  show x = genericShow x 

but at least compiler should append to the error message something like: "Try to rewrite function without point-free style."

Additional context

#3807

PureScript version

0.15.8

@rhendric
Copy link
Member

This is the error message I'd expect (and eta-expanding functions changes their semantics so we don't want to do that automatically), but that doesn't mean we can't enhance it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants