Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 591063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:35:43+00:00 2026-05-13T15:35:43+00:00

I do the following in GHCI: :m + Data.Map let map = fromList [(1,

  • 0

I do the following in GHCI:

:m + Data.Map
let map = fromList [(1, 2)]
lookup 1 map

GHCI knows that map is a (Map Integer Integer). So why does it claim an ambiguity between Prelude.lookup and Data.Map.lookup when the type is clear and can I avoid?

<interactive>:1:0:
    Ambiguous occurrence `lookup'
    It could refer to either `Prelude.lookup', imported from Prelude
                          or `Data.Map.lookup', imported from Data.Map

> :t map
map :: Map Integer Integer
> :t Prelude.lookup
Prelude.lookup :: (Eq a) => a -> [(a, b)] -> Maybe b
> :t Data.Map.lookup
Data.Map.lookup :: (Ord k) => k -> Map k a -> Maybe a
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:35:44+00:00Added an answer on May 13, 2026 at 3:35 pm

    The types are clearly different but Haskell doesn’t allow ad-hoc overloading of names, so you can only choose one lookup to be used without a prefix.

    The typical solution is to import Data.Map qualified:

    > import qualified Data.Map as Map
    

    Then you can say

    > lookup 1 [(1,2), (3,4)]
    Just 2
    > Map.lookup 1 Map.empty
    Nothing
    

    Usually, Haskell libraries either avoid re-using names from the Prelude, or else re-use a whole bunch of them. Data.Map is one of the second, and the authors expect you to import it qualified.

    [Edit to include ephemient’s comment]

    If you want to use Data.Map.lookup without the prefix, you have to hide Prelude.lookup since it’s implicitly imported otherwise:

    import Prelude hiding (lookup) 
    import Data.Map (lookup)
    

    This is a bit weird but might be useful if you use Data.Map.lookup a whole bunch and your data structures are all maps, never alists.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 315k
  • Answers 315k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It is possible that running as a WebStart application, your… May 13, 2026 at 11:11 pm
  • Editorial Team
    Editorial Team added an answer It's a BitmapAsset. May 13, 2026 at 11:11 pm
  • Editorial Team
    Editorial Team added an answer You can't do that because the RouteLink gets rendered on… May 13, 2026 at 11:11 pm

Related Questions

I'm trying to do the exercises in Real World Haskell in a TDD fashion,
I am new to Haskell and trying to fiddle with some test cases I
This is probably a really easy question to answer, but for some reason I'm
Ok, so following on from my previous question I have ended up with the
I do the following in command line: 1) wget ftp://mirrors.kernel.org/gnu/gcc/gcc-3.4.6/gcc-3.4.6.tar.bz2 2) tar -jxf gcc-3.4.6.tar.bz2

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.