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

Related Questions

In GHCI, I type the following: map (+1) [1..10] which returns [2,3,4,5,6,7,8,9,10,11] So far
Consider following function definition in ghci. let myF = sin . cos . sum
I'm using GHCi 7.0.3 with the following program that implements type-level list: {-# LANGUAGE
So here I have the following on GHCI >let addlist [] [] = []
The following program yields an error in ghci: {-# LANGUAGE NoImplicitPrelude #-} import Prelude
Take a quick peek at the following interactive session in GHCi: Prelude> import Control.Applicative
Following is the association between 2 models: class FotoGossip < ActiveRecord::Base has_many :uploads end
Following command will let me know the names of databases. $ mysqlshow But how
With the following sample module: module Exp ( initial, myval ) where data State
So, the idea is that I would take the following code used to run

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.