I'm working on a project that references unordered-containers-0.2.8.0:Data.HashMap.Base.HashMap.
The module containing value of that type does not state where it came from in import sections and I cannot import Data.HashMap.Base.
However :browsing suggests that the type is intended to be abstract at least in some cases.
> :bro Data.HashMap.Lazy
[...]
unordered-containers-0.2.8.0:Data.HashMap.Base.toList ::
unordered-containers-0.2.8.0:Data.HashMap.Base.HashMap k v
-> [(k, v)]
Does it mean I can import functions from either Lazy or Strict variants?
Yes, in the
unordered-containerspackage, the intention is that you either importData.HashMap.LazyorData.HashMap.Strict. Both variants have strict keys (evaluated to WHNF) and differ in whether values are also evaluated to WHNF or not.In the source package for
unordered-containers, there is a hidden moduleData.HashMap.Basethat contains code shared by both the lazy and strict variants. Because this module is hidden (technically, because it is listed in the package's Cabal file under theother-modulesstanza instead of theexposed-modulesstanza), it is not intended to be imported directly, but only indirectly via one of the other two modules.For
toListin particular, the exposed modulesData.HashMap.LazyandData.HashMap.Strictboth use (i.e., re-export) the same definition oftoListdefined in the hidden moduleData.HashMap.Base, which is why you're seeing this in your GHCI browsing.If you import one of the modules in GHCI, then you should be able to inspect
toListand its component types:In fact, you'll discover that the same
HashMapdefinition is used for both strict and lazy variants, so it's not an "abstract" type in the sense you're thinking: both implementations use the same underlying concrete data structure and differ in how the functions operating on that data structure use it.This is true for the
Data.Map.StrictandData.Map.Lazyplain maps, too, by the way. A "strict" map can be used with lazy operations and vice versa, because "strict" and "lazy" maps are the same object. Quoting from the documentation forData.Map.Lazy: