haskell / haskell/error-messages

Ambiguous occurrence ‘map’

Open
#11 14 comments 0 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

[A new user reports confusion](https://discourse.haskell.org/t/ambiguous-occurrence-in-map/2817) about the error message below. I can understand the confusion. The error message is technically correct, of course, but wouldn't it be more helpful to say "To resolve the error change `map` to `Prelude.map` or `Data.Map.map` (if either of those is what you meant) or something else (if you meant something else.".

(Implicit import of `Prelude` is a confounding factor here.)

```
:12:2: error:
Ambiguous occurrence ‘map’
It could refer to
either ‘Prelude.map’,
imported from ‘Prelude’ at modules.hs:1:1
(and originally defined in ‘GHC.Base’)
or ‘Data.Map.map’,
imported from ‘Data.Map’ at modules.hs:5:1-15
(and originally defined in ‘Data.Map.Internal’)
```

EDIT, the op's code which produced the error:

```
import Data.List (nub, sort) --you can selectively import functions
{-import Data.List hiding (nub) you're importing all functions accept the nub-}
-- import qualified Data.Map as M
-- Now, to reference Data.Map's filter function, we just use M.filter
import Data.Map
import qualified Data.Set

numUniques :: (Eq a) => [a] -> Int
numUniques = length . nub
```

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.