Skip to content

Commit 0696e2d

Browse files
committed
Merge pull request #113 from RyanGlScott/master
Add role annotations
2 parents 97a3d51 + 7580708 commit 0696e2d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Data/HashMap/Base.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE ScopedTypeVariables #-}
33
{-# LANGUAGE PatternGuards #-}
44
#if __GLASGOW_HASKELL__ >= 708
5+
{-# LANGUAGE RoleAnnotations #-}
56
{-# LANGUAGE TypeFamilies #-}
67
#endif
78
{-# OPTIONS_GHC -fno-full-laziness -funbox-strict-fields #-}
@@ -145,6 +146,10 @@ data HashMap k v
145146
| Collision !Hash !(A.Array (Leaf k v))
146147
deriving (Typeable)
147148

149+
#if __GLASGOW_HASKELL__ >= 708
150+
type role HashMap nominal representational
151+
#endif
152+
148153
instance (NFData k, NFData v) => NFData (HashMap k v) where
149154
rnf Empty = ()
150155
rnf (BitmapIndexed _ ary) = rnf ary
@@ -607,8 +612,8 @@ adjust f k0 m0 = go h0 k0 0 m0
607612
| otherwise = t
608613
{-# INLINABLE adjust #-}
609614

610-
-- | /O(log n)/ The expression (@'update' f k map@) updates the value @x@ at @k@,
611-
-- (if it is in the map). If (f k x) is @'Nothing', the element is deleted.
615+
-- | /O(log n)/ The expression (@'update' f k map@) updates the value @x@ at @k@,
616+
-- (if it is in the map). If (f k x) is @'Nothing', the element is deleted.
612617
-- If it is (@'Just' y), the key k is bound to the new value y.
613618
update :: (Eq k, Hashable k) => (a -> Maybe a) -> k -> HashMap k a -> HashMap k a
614619
update f = alter (>>= f)

Data/HashSet.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE CPP, DeriveDataTypeable #-}
22
#if __GLASGOW_HASKELL__ >= 708
3+
{-# LANGUAGE RoleAnnotations #-}
34
{-# LANGUAGE TypeFamilies #-}
45
#endif
56
#if __GLASGOW_HASKELL__ >= 702
@@ -95,6 +96,10 @@ newtype HashSet a = HashSet {
9596
asMap :: HashMap a ()
9697
} deriving (Typeable)
9798

99+
#if __GLASGOW_HASKELL__ >= 708
100+
type role HashSet nominal
101+
#endif
102+
98103
instance (NFData a) => NFData (HashSet a) where
99104
rnf = rnf . asMap
100105
{-# INLINE rnf #-}

0 commit comments

Comments
 (0)