haskell / haskell/error-messages
do desugaring yields confusing errors when the argument count is wrong
- Dominant language
- No language data
- Stars
- 76
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
```haskell
module BadError where
{-
I get:
Couldn't match expected type ‘() -> Either String Int’
with actual type ‘Either String Int’
...
|
6 | x <- do_thing arg2
| ^^^^^^^^^^^^^^^^^^
This makes it seem like "do_thing arg2" is short one argument, but it's not!
'confusing' has an undeclared argument ().
-}
confusing :: Int -> String -> () -> Either String Int
confusing arg1 arg2 = do
x <- do_thing arg2
-- ... much stuff
return $ arg1 + 2
where
do_thing :: String -> Either String Int
do_thing = undefined
{-
In this case I think I was misled by the highlighting, it highlights "do_thing
arg2". But the "in the expression" is correct, it fingers the entire do
expression. When desugared, it seems that this is an artifact of the error
highlighting, since the below highlights the entire expression:
-}
-- desugared :: Int -> String -> () -> Either String Int
-- desugared arg1 arg2 =
-- do_thing arg2 >>= \x -> return $ arg1 + 2
-- where
-- do_thing :: String -> Either String Int
-- do_thing = undefined
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.