Skip to content

Display type class members and let identifiers in errors - #3463

Closed
LiamGoodacre wants to merge 1 commit into
purescript:masterfrom
LiamGoodacre:feature/instance-let-error-message
Closed

Display type class members and let identifiers in errors#3463
LiamGoodacre wants to merge 1 commit into
purescript:masterfrom
LiamGoodacre:feature/instance-let-error-message

Conversation

@LiamGoodacre

Copy link
Copy Markdown
Member

Example code:

class Abc a where
  abc :: a -> a

instance abcInt :: Abc Int where
  abc a = let bac :: Int -> Int
              bac = 3 in bac a

Error diff:

    Could not match type
      Int
    with type
      Int -> Int

  while checking that type Int
    is at least as general as type Int -> Int
  while checking that expression 3
    has type Int -> Int
+ in value declaration bac
+ in value declaration abc
  in value declaration abcInt

I think this could be sufficient for the second half of #3390.

@LiamGoodacre

Copy link
Copy Markdown
Member Author

Okay I broke something, this isn't quite ready yet.

@LiamGoodacre

Copy link
Copy Markdown
Member Author

Feels a bit hacky too. Will re-think.

@hdgarrood

Copy link
Copy Markdown
Contributor

It's perhaps worth noting that the --verbose-errors flag already gets you something somewhat similar (if a bit more, uh, verbose):

  Could not match type
       
    Int
       
  with type
              
    Int -> Int
              

while trying to match type Int
  with type Int -> Int
while checking that type Int
  is at least as general as type Int -> Int
while checking that expression 3
  has type Int -> Int
while checking that expression let      
                                 bac = 3
                               in bac a 
  has type Int
while checking that expression \a ->      
                                 let      
                                   bac = 3
                                 in bac a 
  has type Int -> Int
while checking that expression Abc { abc: \a ->      
                                            let      
                                              bac = 3
                                            in bac a 
                                   }                 
  has type { abc :: Int -> Int
           }                  
in value declaration abcInt

@hdgarrood

hdgarrood commented Mar 7, 2019

Copy link
Copy Markdown
Contributor

I'm not sure how I feel about this approach actually. I think I'd prefer we leave this as is and instead improve error spans and implement printing actual code in errors (#1898) to address the issue of it being difficult to work out which bit of your code is causing the problem.

@hdgarrood

Copy link
Copy Markdown
Contributor

Shall we close this (and #3390)?

@LiamGoodacre
LiamGoodacre deleted the feature/instance-let-error-message branch April 20, 2019 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants