11{-# LANGUAGE BangPatterns #-}
2+ {-# LANGUAGE CPP #-}
23{-# LANGUAGE DeriveGeneric #-}
34{-# LANGUAGE FlexibleContexts #-}
45{-# LANGUAGE FlexibleInstances #-}
@@ -25,8 +26,8 @@ module Data.VMap.KVVector (
2526 fromDistinctAscListN ,
2627 fromList ,
2728 fromListN ,
28- mapValsKVVector ,
29- mapWithKeyKVVector ,
29+ -- mapValsKVVector,
30+ -- mapWithKeyKVVector,
3031 memberKVVector ,
3132 lookupKVVector ,
3233 lookupDefaultKVVector ,
@@ -58,6 +59,13 @@ import qualified Data.Vector.Storable as VS
5859import qualified GHC.Exts as Exts
5960import GHC.Generics
6061import NoThunks.Class
62+ #if MIN_VERSION_vector(0, 13, 2)
63+ import qualified Data.Vector.Strict as VBS
64+
65+ instance NoThunks a => NoThunks (VBS. Vector a ) where
66+ showTypeOf _ = " Boxed..StrictVector"
67+ wNoThunks ctxt = noThunksInValues ctxt . VBS. toList
68+ #endif
6169
6270-- | Convert a __sorted__ key/value vector into a `Map.Map`
6371toMap ::
@@ -173,26 +181,28 @@ fromAscListWithKeyN n f xs
173181 VG. create $ VGM. unsafeNew n >>= fillWithList xs >>= removeDuplicates (\ k v1 v2 -> f k v2 v1)
174182{-# INLINE fromAscListWithKeyN #-}
175183
176- mapValsKVVector ::
177- (VG. Vector vv a , VG. Vector vv b ) =>
178- (a -> b ) ->
179- KVVector kv vv (k , a ) ->
180- KVVector kv vv (k , b )
181- mapValsKVVector f vec =
182- KVVector {keysVector = keysVector vec, valsVector = VG. map f (valsVector vec)}
183- {-# INLINE mapValsKVVector #-}
184-
185- mapWithKeyKVVector ::
186- (VG. Vector kv k , VG. Vector vv a , VG. Vector vv b ) =>
187- (k -> a -> b ) ->
188- KVVector kv vv (k , a ) ->
189- KVVector kv vv (k , b )
190- mapWithKeyKVVector f KVVector {.. } =
191- KVVector
192- { keysVector = keysVector
193- , valsVector = VG. imap (\ i -> f (keysVector VG. ! i)) valsVector
194- }
195- {-# INLINE mapWithKeyKVVector #-}
184+ -- These guys are too lazy for the KVVector and would require `Data.Vector.Strict`
185+ --
186+ -- mapValsKVVector ::
187+ -- (VG.Vector vv a, VG.Vector vv b) =>
188+ -- (a -> b) ->
189+ -- KVVector kv vv (k, a) ->
190+ -- KVVector kv vv (k, b)
191+ -- mapValsKVVector f vec =
192+ -- KVVector {keysVector = keysVector vec, valsVector = VG.map f (valsVector vec)}
193+ -- {-# INLINE mapValsKVVector #-}
194+
195+ -- mapWithKeyKVVector ::
196+ -- (VG.Vector kv k, VG.Vector vv a, VG.Vector vv b) =>
197+ -- (k -> a -> b) ->
198+ -- KVVector kv vv (k, a) ->
199+ -- KVVector kv vv (k, b)
200+ -- mapWithKeyKVVector f KVVector {..} =
201+ -- KVVector
202+ -- { keysVector = keysVector
203+ -- , valsVector = VG.imap (\i -> f (keysVector VG.! i)) valsVector
204+ -- }
205+ -- {-# INLINE mapWithKeyKVVector #-}
196206
197207internKVVectorMaybe :: (VG. Vector kv k , Ord k ) => k -> KVVector kv vv (k , v ) -> Maybe k
198208internKVVectorMaybe key (KVVector keys _values) =
0 commit comments