haskell / haskell/error-messages
Better error messages for Num literals
- Dominant language
- No language data
- Stars
- 76
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
I hope, this is the correct way to post this, since this repo seems to be pretty new.
In my experience, one of the most annoying error messages in GHC is when you try to assign a number literal to a type which does not implement `Num`.
```haskell
x :: String
x = 5
```
What you would expect as a beginner is something like *Could not match type Int with String*, but because Num literals are overloaded in Haskell, you actually get the following.
```
:2:18: error:
• No instance for (Num String) arising from the literal ‘5’
• In the expression: 5
In an equation for ‘x’: x = 5
```
If the source of this *No instance for (Num String)* part is a literal, the compiler could provide a more useful message.
Something like *Expected a String, but got a Num literal* seems a lot more helpful to newbies.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.