haskell / haskell/error-messages

Better error messages for Num literals

Open
#5 19 comments 9 reactions 0 assignees View on GitHub
status:Composing error message tool:GHC type:error-message
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.