Skip to content

Commit a3a198c

Browse files
authored
Merge pull request #123 from dolio/master
Use mapM in createT because ST wasn't Applicative in 7.0
2 parents d0dac68 + d6ad33a commit a3a198c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Data/Vector/Generic.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@ mkNoRepType :: String -> DataType
217217
mkNoRepType = mkNorepType
218218
#endif
219219

220-
#if !MIN_VERSION_base(4,8,0)
221-
import Data.Traversable (Traversable, traverse)
222-
#endif
220+
import qualified Data.Traversable as T (Traversable(mapM))
223221

224222
-- Length information
225223
-- ------------------
@@ -723,9 +721,11 @@ create :: Vector v a => (forall s. ST s (Mutable v s a)) -> v a
723721
create p = new (New.create p)
724722

725723
-- | Execute the monadic action and freeze the resulting vectors.
726-
createT :: (Traversable f, Vector v a) => (forall s. ST s (f (Mutable v s a))) -> f (v a)
724+
createT
725+
:: (T.Traversable f, Vector v a)
726+
=> (forall s. ST s (f (Mutable v s a))) -> f (v a)
727727
{-# INLINE createT #-}
728-
createT p = runST (p >>= traverse unsafeFreeze)
728+
createT p = runST (p >>= T.mapM unsafeFreeze)
729729

730730
-- Restricting memory usage
731731
-- ------------------------

tests/Tests/Vector.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Tests.Vector (tests) where
33
import Boilerplater
44
import Utilities as Util
55

6-
import Data.Traversable (Traversable(..))
6+
import qualified Data.Traversable as T (Traversable(..))
77
import Data.Foldable (Foldable(foldMap))
88

99
import qualified Data.Vector.Generic as V
@@ -73,7 +73,7 @@ import Control.Monad.Trans.Writer
7373
instance Foldable ((,) a) where
7474
foldMap f (_, b) = f b
7575

76-
instance Traversable ((,) a) where
76+
instance T.Traversable ((,) a) where
7777
traverse f (a, b) = fmap ((,) a) $ f b
7878
#endif
7979

@@ -233,7 +233,7 @@ testPolymorphicFunctions _ = $(testProperties [
233233
= (\n _ _ -> n < 1000) ===> V.iterateN `eq` (\n f -> take n . iterate f)
234234

235235
prop_createT :: P ((a, v a) -> (a, v a))
236-
prop_createT = (\v -> V.createT (traverse V.thaw v)) `eq` id
236+
prop_createT = (\v -> V.createT (T.mapM V.thaw v)) `eq` id
237237

238238
prop_head :: P (v a -> a) = not . V.null ===> V.head `eq` head
239239
prop_last :: P (v a -> a) = not . V.null ===> V.last `eq` last

0 commit comments

Comments
 (0)