【发布时间】:2010-01-31 22:24:56
【问题描述】:
我在 GHCI 中执行以下操作:
:m + Data.Map
let map = fromList [(1, 2)]
lookup 1 map
GHCI 知道 map 是一个 (Map Integer Integer)。那么,当类型明确并且我可以避免时,为什么它声称 Prelude.lookup 和 Data.Map.lookup 之间存在歧义?
<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
【问题讨论】: