Skip to content

Commit 6f1a92f

Browse files
authored
Rename and expose internal modules (#283)
This also removes some "Stability" annotations from internal modules. Context: #211.
1 parent afcbc77 commit 6f1a92f

File tree

12 files changed

+128
-48
lines changed

12 files changed

+128
-48
lines changed

Data/HashMap/Base.hs renamed to Data/HashMap/Internal.hs

+18-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,19 @@
1111
#endif
1212
{-# OPTIONS_GHC -fno-full-laziness -funbox-strict-fields #-}
1313

14-
module Data.HashMap.Base
14+
-- | = WARNING
15+
--
16+
-- This module is considered __internal__.
17+
--
18+
-- The Package Versioning Policy __does not apply__.
19+
--
20+
-- The contents of this module may change __in any way whatsoever__
21+
-- and __without any warning__ between minor versions of this package.
22+
--
23+
-- Authors importing this module are expected to track development
24+
-- closely.
25+
26+
module Data.HashMap.Internal
1527
(
1628
HashMap(..)
1729
, Leaf(..)
@@ -140,11 +152,11 @@ import GHC.Exts ((==#), build, reallyUnsafePtrEquality#)
140152
import Prelude hiding (filter, foldl, foldr, lookup, map, null, pred)
141153
import Text.Read hiding (step)
142154

143-
import qualified Data.HashMap.Array as A
155+
import qualified Data.HashMap.Internal.Array as A
144156
import qualified Data.Hashable as H
145157
import Data.Hashable (Hashable)
146-
import Data.HashMap.Unsafe (runST)
147-
import Data.HashMap.List (isPermutationBy, unorderedCompare)
158+
import Data.HashMap.Internal.Unsafe (runST)
159+
import Data.HashMap.Internal.List (isPermutationBy, unorderedCompare)
148160
import Data.Typeable (Typeable)
149161

150162
import GHC.Exts (isTrue#)
@@ -283,7 +295,7 @@ fromListConstr :: Constr
283295
fromListConstr = mkConstr hashMapDataType "fromList" [] Prefix
284296

285297
hashMapDataType :: DataType
286-
hashMapDataType = mkDataType "Data.HashMap.Base.HashMap" [fromListConstr]
298+
hashMapDataType = mkDataType "Data.HashMap.Internal.HashMap" [fromListConstr]
287299

288300
type Hash = Word
289301
type Bitmap = Word
@@ -729,7 +741,7 @@ lookupDefault def k t = findWithDefault def k t
729741
#endif
730742
(!) m k = case lookup k m of
731743
Just v -> v
732-
Nothing -> error "Data.HashMap.Base.(!): key not found"
744+
Nothing -> error "Data.HashMap.Internal.(!): key not found"
733745
{-# INLINABLE (!) #-}
734746

735747
infixl 9 !

Data/HashMap/Array.hs renamed to Data/HashMap/Internal/Array.hs

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
{-# LANGUAGE BangPatterns, CPP, MagicHash, Rank2Types, UnboxedTuples, ScopedTypeVariables #-}
22
{-# OPTIONS_GHC -fno-full-laziness -funbox-strict-fields #-}
33

4-
-- | Zero based arrays.
4+
-- | = WARNING
5+
--
6+
-- This module is considered __internal__.
7+
--
8+
-- The Package Versioning Policy __does not apply__.
9+
--
10+
-- The contents of this module may change __in any way whatsoever__
11+
-- and __without any warning__ between minor versions of this package.
12+
--
13+
-- Authors importing this module are expected to track development
14+
-- closely.
15+
--
16+
-- = Description
17+
--
18+
-- Zero based arrays.
519
--
620
-- Note that no bounds checking are performed.
7-
module Data.HashMap.Array
21+
module Data.HashMap.Internal.Array
822
( Array
923
, MArray
1024

@@ -88,7 +102,7 @@ import Data.Monoid (Monoid (..))
88102
import qualified Prelude
89103
#endif
90104

91-
import Data.HashMap.Unsafe (runST)
105+
import Data.HashMap.Internal.Unsafe (runST)
92106
import Control.Monad ((>=>))
93107

94108

@@ -163,9 +177,9 @@ copyMutableArray# = copySmallMutableArray#
163177
-- This fugly hack is brought by GHC's apparent reluctance to deal
164178
-- with MagicHash and UnboxedTuples when inferring types. Eek!
165179
# define CHECK_BOUNDS(_func_,_len_,_k_) \
166-
if (_k_) < 0 || (_k_) >= (_len_) then error ("Data.HashMap.Array." ++ (_func_) ++ ": bounds error, offset " ++ show (_k_) ++ ", length " ++ show (_len_)) else
180+
if (_k_) < 0 || (_k_) >= (_len_) then error ("Data.HashMap.Internal.Array." ++ (_func_) ++ ": bounds error, offset " ++ show (_k_) ++ ", length " ++ show (_len_)) else
167181
# define CHECK_OP(_func_,_op_,_lhs_,_rhs_) \
168-
if not ((_lhs_) _op_ (_rhs_)) then error ("Data.HashMap.Array." ++ (_func_) ++ ": Check failed: _lhs_ _op_ _rhs_ (" ++ show (_lhs_) ++ " vs. " ++ show (_rhs_) ++ ")") else
182+
if not ((_lhs_) _op_ (_rhs_)) then error ("Data.HashMap.Internal.Array." ++ (_func_) ++ ": Check failed: _lhs_ _op_ _rhs_ (" ++ show (_lhs_) ++ " vs. " ++ show (_rhs_) ++ ")") else
169183
# define CHECK_GT(_func_,_lhs_,_rhs_) CHECK_OP(_func_,>,_lhs_,_rhs_)
170184
# define CHECK_LE(_func_,_lhs_,_rhs_) CHECK_OP(_func_,<=,_lhs_,_rhs_)
171185
# define CHECK_EQ(_func_,_lhs_,_rhs_) CHECK_OP(_func_,==,_lhs_,_rhs_)
@@ -448,7 +462,7 @@ foldMap f = \ary0 -> case length ary0 of
448462
{-# INLINE foldMap #-}
449463

450464
undefinedElem :: a
451-
undefinedElem = error "Data.HashMap.Array: Undefined element"
465+
undefinedElem = error "Data.HashMap.Internal.Array: Undefined element"
452466
{-# NOINLINE undefinedElem #-}
453467

454468
thaw :: Array e -> Int -> Int -> ST s (MArray s e)

Data/HashMap/List.hs renamed to Data/HashMap/Internal/List.hs

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
{-# LANGUAGE ScopedTypeVariables #-}
22
{-# OPTIONS_GHC -fno-full-laziness -funbox-strict-fields #-}
3-
-- | Extra list functions
3+
4+
-- | = WARNING
5+
--
6+
-- This module is considered __internal__.
7+
--
8+
-- The Package Versioning Policy __does not apply__.
9+
--
10+
-- The contents of this module may change __in any way whatsoever__
11+
-- and __without any warning__ between minor versions of this package.
12+
--
13+
-- Authors importing this module are expected to track development
14+
-- closely.
15+
--
16+
-- = Description
17+
--
18+
-- Extra list functions
419
--
520
-- In separate module to aid testing.
6-
module Data.HashMap.List
21+
module Data.HashMap.Internal.List
722
( isPermutationBy
823
, deleteBy
924
, unorderedCompare

Data/HashMap/Strict/Base.hs renamed to Data/HashMap/Internal/Strict.hs

+21-8
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@
88
-- Copyright : 2010-2012 Johan Tibell
99
-- License : BSD-style
1010
-- Maintainer : [email protected]
11-
-- Stability : provisional
1211
-- Portability : portable
1312
--
13+
-- = WARNING
14+
--
15+
-- This module is considered __internal__.
16+
--
17+
-- The Package Versioning Policy __does not apply__.
18+
--
19+
-- The contents of this module may change __in any way whatsoever__
20+
-- and __without any warning__ between minor versions of this package.
21+
--
22+
-- Authors importing this module are expected to track development
23+
-- closely.
24+
--
25+
-- = Description
26+
--
1427
-- A map from /hashable/ keys to values. A map cannot contain
1528
-- duplicate keys; each key can map to at most one value. A 'HashMap'
1629
-- makes no guarantees as to the order of its elements.
@@ -23,7 +36,7 @@
2336
-- Many operations have a average-case complexity of /O(log n)/. The
2437
-- implementation uses a large base (i.e. 16) so in practice these
2538
-- operations are constant time.
26-
module Data.HashMap.Strict.Base
39+
module Data.HashMap.Internal.Strict
2740
(
2841
-- * Strictness properties
2942
-- $strictness
@@ -107,15 +120,15 @@ import qualified Data.List as L
107120
import Data.Hashable (Hashable)
108121
import Prelude hiding (map, lookup)
109122

110-
import qualified Data.HashMap.Array as A
111-
import qualified Data.HashMap.Base as HM
112-
import Data.HashMap.Base hiding (
123+
import qualified Data.HashMap.Internal.Array as A
124+
import qualified Data.HashMap.Internal as HM
125+
import Data.HashMap.Internal hiding (
113126
alter, alterF, adjust, fromList, fromListWith, fromListWithKey,
114127
insert, insertWith,
115128
differenceWith, intersectionWith, intersectionWithKey, map, mapWithKey,
116129
mapMaybe, mapMaybeWithKey, singleton, update, unionWith, unionWithKey,
117130
traverseWithKey)
118-
import Data.HashMap.Unsafe (runST)
131+
import Data.HashMap.Internal.Unsafe (runST)
119132
#if MIN_VERSION_base(4,8,0)
120133
import Data.Functor.Identity
121134
#endif
@@ -310,7 +323,7 @@ alterF f = \ !k !m ->
310323
{-# INLINABLE [0] alterF #-}
311324

312325
#if MIN_VERSION_base(4,8,0)
313-
-- See notes in Data.HashMap.Base
326+
-- See notes in Data.HashMap.Internal
314327
test_bottom :: a
315328
test_bottom = error "Data.HashMap.alterF internal error: hit test_bottom"
316329

@@ -322,7 +335,7 @@ impossibleAdjust = error "Data.HashMap.alterF internal error: impossible adjust"
322335

323336
{-# RULES
324337

325-
-- See detailed notes on alterF rules in Data.HashMap.Base.
338+
-- See detailed notes on alterF rules in Data.HashMap.Internal.
326339

327340
"alterFWeird" forall f. alterF f =
328341
alterFWeird (f Nothing) (f (Just test_bottom)) f

Data/HashMap/Unsafe.hs renamed to Data/HashMap/Internal/Unsafe.hs

+16-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,29 @@
44
{-# LANGUAGE MagicHash, Rank2Types, UnboxedTuples #-}
55
#endif
66

7-
-- | This module exports a workaround for this bug:
7+
-- | = WARNING
8+
--
9+
-- This module is considered __internal__.
10+
--
11+
-- The Package Versioning Policy __does not apply__.
12+
--
13+
-- The contents of this module may change __in any way whatsoever__
14+
-- and __without any warning__ between minor versions of this package.
15+
--
16+
-- Authors importing this module are expected to track development
17+
-- closely.
18+
--
19+
-- = Description
20+
--
21+
-- This module exports a workaround for this bug:
822
--
923
-- http://hackage.haskell.org/trac/ghc/ticket/5916
1024
--
1125
-- Please read the comments in ghc/libraries/base/GHC/ST.lhs to
1226
-- understand what's going on here.
1327
--
1428
-- Code that uses this module should be compiled with -fno-full-laziness
15-
module Data.HashMap.Unsafe
29+
module Data.HashMap.Internal.Unsafe
1630
( runST
1731
) where
1832

Data/HashMap/Lazy.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ module Data.HashMap.Lazy
100100
, HS.keysSet
101101
) where
102102

103-
import Data.HashMap.Base as HM
104-
import qualified Data.HashSet.Base as HS
103+
import Data.HashMap.Internal as HM
104+
import qualified Data.HashSet.Internal as HS
105105
import Prelude ()
106106

107107
-- $strictness

Data/HashMap/Strict.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ module Data.HashMap.Strict
9999
, HS.keysSet
100100
) where
101101

102-
import Data.HashMap.Strict.Base as HM
103-
import qualified Data.HashSet.Base as HS
102+
import Data.HashMap.Internal.Strict as HM
103+
import qualified Data.HashSet.Internal as HS
104104
import Prelude ()
105105

106106
-- $strictness

Data/HashSet.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,5 @@ module Data.HashSet
137137
, fromMap
138138
) where
139139

140-
import Data.HashSet.Base
140+
import Data.HashSet.Internal
141141
import Prelude ()

Data/HashSet/Base.hs renamed to Data/HashSet/Internal.hs

+19-6
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@
99

1010
------------------------------------------------------------------------
1111
-- |
12-
-- Module : Data.HashSet.Base
12+
-- Module : Data.HashSet.Internal
1313
-- Copyright : 2011 Bryan O'Sullivan
1414
-- License : BSD-style
1515
-- Maintainer : [email protected]
16-
-- Stability : provisional
1716
-- Portability : portable
1817
--
18+
-- = WARNING
19+
--
20+
-- This module is considered __internal__.
21+
--
22+
-- The Package Versioning Policy __does not apply__.
23+
--
24+
-- The contents of this module may change __in any way whatsoever__
25+
-- and __without any warning__ between minor versions of this package.
26+
--
27+
-- Authors importing this module are expected to track development
28+
-- closely.
29+
--
30+
-- = Description
31+
--
1932
-- A set of /hashable/ values. A set cannot contain duplicate items.
2033
-- A 'HashSet' makes no guarantees as to the order of its elements.
2134
--
@@ -28,7 +41,7 @@
2841
-- implementation uses a large base (i.e. 16) so in practice these
2942
-- operations are constant time.
3043

31-
module Data.HashSet.Base
44+
module Data.HashSet.Internal
3245
(
3346
HashSet
3447

@@ -79,7 +92,7 @@ module Data.HashSet.Base
7992

8093
import Control.DeepSeq (NFData(..))
8194
import Data.Data hiding (Typeable)
82-
import Data.HashMap.Base
95+
import Data.HashMap.Internal
8396
( HashMap, foldMapWithKey, foldlWithKey, foldrWithKey
8497
, equalKeys, equalKeys1)
8598
import Data.Hashable (Hashable(hashWithSalt))
@@ -91,7 +104,7 @@ import Data.Monoid (Monoid(..))
91104
import GHC.Exts (build)
92105
import Prelude hiding (filter, foldr, foldl, map, null)
93106
import qualified Data.Foldable as Foldable
94-
import qualified Data.HashMap.Base as H
107+
import qualified Data.HashMap.Internal as H
95108
import qualified Data.List as List
96109
import Data.Typeable (Typeable)
97110
import Text.Read
@@ -257,7 +270,7 @@ fromListConstr :: Constr
257270
fromListConstr = mkConstr hashSetDataType "fromList" [] Prefix
258271

259272
hashSetDataType :: DataType
260-
hashSetDataType = mkDataType "Data.HashSet.Base.HashSet" [fromListConstr]
273+
hashSetDataType = mkDataType "Data.HashSet.Internal.HashSet" [fromListConstr]
261274

262275
-- | /O(1)/ Construct an empty set.
263276
--

tests/List.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Main (main) where
22

3-
import Data.HashMap.List
3+
import Data.HashMap.Internal.List
44
import Data.List (nub, sort, sortBy)
55
import Data.Ord (comparing)
66

@@ -9,7 +9,7 @@ import Test.Framework.Providers.QuickCheck2 (testProperty)
99
import Test.QuickCheck ((==>), (===), property, Property)
1010

1111
tests :: Test
12-
tests = testGroup "Data.HashMap.List"
12+
tests = testGroup "Data.HashMap.Internal.List"
1313
[ testProperty "isPermutationBy" pIsPermutation
1414
, testProperty "isPermutationBy of different length" pIsPermutationDiffLength
1515
, testProperty "pUnorderedCompare" pUnorderedCompare

unordered-containers.cabal

+7-8
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ flag debug
3737

3838
library
3939
exposed-modules:
40+
Data.HashMap.Internal
41+
Data.HashMap.Internal.Array
42+
Data.HashMap.Internal.List
43+
Data.HashMap.Internal.Strict
44+
Data.HashMap.Internal.Unsafe
4045
Data.HashMap.Lazy
4146
Data.HashMap.Strict
4247
Data.HashSet
43-
other-modules:
44-
Data.HashMap.Array
45-
Data.HashMap.Base
46-
Data.HashMap.Strict.Base
47-
Data.HashMap.List
48-
Data.HashMap.Unsafe
49-
Data.HashSet.Base
48+
Data.HashSet.Internal
5049

5150
build-depends:
5251
base >= 4.7 && < 5,
@@ -130,7 +129,7 @@ test-suite list-tests
130129
hs-source-dirs: tests .
131130
main-is: List.hs
132131
other-modules:
133-
Data.HashMap.List
132+
Data.HashMap.Internal.List
134133
type: exitcode-stdio-1.0
135134

136135
build-depends:

utils/Stats.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
{-# OPTIONS_GHC -funbox-strict-fields #-}
44
module Stats where
55

6-
import qualified Data.HashMap.Array as A
7-
import Data.HashMap.Base (HashMap(..))
8-
import qualified Data.HashMap.Base as HM
6+
import qualified Data.HashMap.Internal.Array as A
7+
import Data.HashMap.Internal (HashMap(..))
8+
import qualified Data.HashMap.Internal as HM
99
import Data.Semigroup
1010

1111
data Histogram = H {

0 commit comments

Comments
 (0)