diff --git a/vector/src/Data/Vector/Storable.hs b/vector/src/Data/Vector/Storable.hs index 15bccd24..c798a5aa 100644 --- a/vector/src/Data/Vector/Storable.hs +++ b/vector/src/Data/Vector/Storable.hs @@ -1029,7 +1029,8 @@ izipWith6 = G.izipWith6 -- | Checks whether two values are the same vector: they have same length -- and share the same buffer. -- --- >>> let xs = fromList [0/0::Double] in isSameVector xs xs +-- >>> import qualified Data.Vector.Storable as VS +-- >>> let xs = VS.fromList [0/0::Double] in VS.isSameVector xs xs -- True isSameVector :: (Storable a) => Vector a -> Vector a -> Bool {-# INLINE isSameVector #-} diff --git a/vector/src/Data/Vector/Unboxed/Base.hs b/vector/src/Data/Vector/Unboxed/Base.hs index 85e20ee8..d1d1ad7f 100644 --- a/vector/src/Data/Vector/Unboxed/Base.hs +++ b/vector/src/Data/Vector/Unboxed/Base.hs @@ -304,6 +304,7 @@ idU = id -- >>> :set -XTypeFamilies -XStandaloneDeriving -XDerivingVia -- >>> :set -XMultiParamTypeClasses -XTypeOperators -XFlexibleInstances -- >>> import qualified Data.Vector.Unboxed as VU +-- >>> import qualified Data.Vector.Unboxed.Mutable as MVU -- >>> import qualified Data.Vector.Generic as VG -- >>> import qualified Data.Vector.Generic.Mutable as VGM -- >>> :{ @@ -316,8 +317,8 @@ idU = id -- {-# INLINE fromURepr #-} -- newtype instance VU.MVector s (Foo a) = MV_Foo (VU.MVector s (Int, a)) -- newtype instance VU.Vector (Foo a) = V_Foo (VU.Vector (Int, a)) --- deriving via (Foo a `VU.As` (Int, a)) instance VU.Unbox a => VGM.MVector MVector (Foo a) --- deriving via (Foo a `VU.As` (Int, a)) instance VU.Unbox a => VG.Vector Vector (Foo a) +-- deriving via (Foo a `VU.As` (Int, a)) instance VU.Unbox a => VGM.MVector MVU.MVector (Foo a) +-- deriving via (Foo a `VU.As` (Int, a)) instance VU.Unbox a => VG.Vector VU.Vector (Foo a) -- instance VU.Unbox a => VU.Unbox (Foo a) -- :} -- @@ -325,8 +326,8 @@ idU = id -- It's also possible to use generic-based instance for 'IsoUnbox' -- which should work for all product types. -- --- >>> :set -XTypeFamilies -XStandaloneDeriving -XDerivingVia -XDeriveGeneric --- >>> :set -XMultiParamTypeClasses -XTypeOperators -XFlexibleInstances +-- >>> :set -XMultiParamTypeClasses -XTypeOperators -XFlexibleInstances -XDeriveGeneric +-- >>> :set -XDerivingVia -- >>> import qualified Data.Vector.Unboxed as VU -- >>> import qualified Data.Vector.Generic as VG -- >>> import qualified Data.Vector.Generic.Mutable as VGM diff --git a/vector/tests/doctests.hs b/vector/tests/doctests.hs index 36388d9c..b0895764 100644 --- a/vector/tests/doctests.hs +++ b/vector/tests/doctests.hs @@ -1,4 +1,38 @@ import Test.DocTest (doctest) +-- Doctests are weirdly fragile. For example running tests for module +-- A (D.V.Unboxed.Base) could cause tests in unrelated woudle B +-- (D.V.Storable) to start failing with weird errors. +-- +-- In order to avoid this one would want to run doctests with +-- per-module granularity but this cause another sort of problems! +-- When we load only single module and use import doctests then some +-- data types may come from built library and some from ghci session. +-- +-- This could be remedied by running doctests for groups of modules. +-- This _is_ convoluted setup but doctests now works for GHC9.4 main :: IO () -main = doctest [ "-Iinclude" , "-Iinternal" , "-XHaskell2010" , "src/Data" ] +main = mapM_ run modGroups + where + run mods = do + mapM_ putStrLn mods + doctest $ ["-Iinclude", "-Iinternal", "-XHaskell2010"] ++ mods + -- + modGroups = + [ [ "src/Data/Vector/Storable/Mutable.hs" + , "src/Data/Vector/Storable.hs" + ] + , [ "src/Data/Vector.hs" + , "src/Data/Vector/Mutable.hs" + ] + , [ "src/Data/Vector/Generic.hs" + , "src/Data/Vector/Generic/Mutable.hs" + ] + , [ "src/Data/Vector/Primitive.hs" + , "src/Data/Vector/Primitive/Mutable.hs" + ] + , [ "src/Data/Vector/Unboxed.hs" + , "src/Data/Vector/Unboxed/Mutable.hs" + , "src/Data/Vector/Unboxed/Base.hs" + ] + ]