Skip to content

Commit a44dfb1

Browse files
committed
Rework export lists for unboxed vectors
We have 3 sorts of data instances: 1. Constructors that we must exports. Data instances which are used in deriving via (UnboxViaPrim etc.). When constructors aren't visible deriving won't work. They were exported before. 2. Constructors which are safe to use. Newtype vectors over underlying representation. Now they're exported from both immutable and mutable 3. Dangerous and unsafe ones: tuple and unit instances. They're exported from Unsafe module. Mutable module reexports deprecated pattern synonym.
1 parent 94750e3 commit a44dfb1

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

vector/src/Data/Vector/Unboxed.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@
6868
-- @
6969
module Data.Vector.Unboxed (
7070
-- * Unboxed vectors
71-
Vector(V_UnboxAs, V_UnboxViaPrim, V_UnboxViaStorable,V_DoNotUnboxLazy,V_DoNotUnboxStrict,V_DoNotUnboxNormalForm),
71+
Vector(V_UnboxAs, V_UnboxViaPrim, V_UnboxViaStorable,V_DoNotUnboxLazy,V_DoNotUnboxStrict,V_DoNotUnboxNormalForm,
72+
V_Int,V_Int8,V_Int16,V_Int32,V_Int64,V_Word,V_Word8,V_Word16,V_Word32,V_Word64,V_Float,V_Double,
73+
V_Char,V_Bool,V_Complex,V_Identity,V_Down,V_Dual,V_Sum,V_Product,V_Min,V_Max,V_First,V_Last,
74+
V_WrappedMonoid,V_Arg,V_Any,V_All,V_Const,V_Alt,V_Compose),
7275
MVector(..), Unbox,
7376

7477
-- * Accessors

vector/src/Data/Vector/Unboxed/Mutable.hs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-# LANGUAGE CPP #-}
2-
2+
{-# LANGUAGE PatternSynonyms #-}
33
-- |
44
-- Module : Data.Vector.Unboxed.Mutable
55
-- Copyright : (c) Roman Leshchinskiy 2009-2010
@@ -16,7 +16,11 @@
1616

1717
module Data.Vector.Unboxed.Mutable (
1818
-- * Mutable vectors of primitive types
19-
MVector(..), IOVector, STVector, Unbox,
19+
MVector(MV_UnboxViaPrim, MV_UnboxViaStorable, MV_DoNotUnboxLazy, MV_DoNotUnboxStrict, MV_DoNotUnboxNormalForm, MV_UnboxAs,
20+
MV_Int,MV_Int8,MV_Int16,MV_Int32,MV_Int64,MV_Word,MV_Word8,MV_Word16,MV_Word32,MV_Word64,MV_Float,MV_Double,
21+
MV_Char,MV_Bool,MV_Complex,MV_Identity,MV_Down,MV_Dual,MV_Sum,MV_Product,MV_Min,MV_Max,MV_First,MV_Last,
22+
MV_WrappedMonoid,MV_Arg,MV_Any,MV_All,MV_Const,MV_Alt,MV_Compose),
23+
IOVector, STVector, Unbox,
2024

2125
-- * Accessors
2226

@@ -65,7 +69,10 @@ module Data.Vector.Unboxed.Mutable (
6569
-- ** Filling and copying
6670
set, copy, move, unsafeCopy, unsafeMove,
6771
-- * Re-exports
68-
PrimMonad, PrimState, RealWorld
72+
PrimMonad, PrimState, RealWorld,
73+
-- * Deprecated
74+
pattern MV_Unit,
75+
pattern MV_2, pattern MV_3, pattern MV_4, pattern MV_5, pattern MV_6
6976
) where
7077

7178
import Data.Vector.Unboxed.Unsafe (MVector, STVector,Unbox,IOVector)
@@ -803,3 +810,36 @@ unzip6 (U.MV_6 _ as bs cs ds es fs) = (as, bs, cs, ds, es, fs)
803810

804811
-- $setup
805812
-- >>> import Prelude (Char, (*), ($))
813+
814+
815+
pattern MV_Unit :: Int -> MVector s ()
816+
pattern MV_Unit i = U.MV_Unit i
817+
{-# COMPLETE MV_Unit #-}
818+
{-# DEPRECATED MV_Unit "Import constructor from Data.Vector.Unboxed.Unsafe" #-}
819+
820+
pattern MV_2 :: Int -> MVector s a -> MVector s b -> MVector s (a,b)
821+
pattern MV_2 i va vb = U.MV_2 i va vb
822+
{-# COMPLETE MV_2 #-}
823+
{-# DEPRECATED MV_2 "Import constructor from Data.Vector.Unboxed.Unsafe" #-}
824+
825+
pattern MV_3 :: Int -> MVector s a -> MVector s b -> MVector s c -> MVector s (a,b,c)
826+
pattern MV_3 i va vb vc = U.MV_3 i va vb vc
827+
{-# COMPLETE MV_3 #-}
828+
{-# DEPRECATED MV_3 "Import constructor from Data.Vector.Unboxed.Unsafe" #-}
829+
830+
pattern MV_4 :: Int -> MVector s a -> MVector s b -> MVector s c -> MVector s d -> MVector s (a,b,c,d)
831+
pattern MV_4 i va vb vc vd = U.MV_4 i va vb vc vd
832+
{-# COMPLETE MV_4 #-}
833+
{-# DEPRECATED MV_4 "Import constructor from Data.Vector.Unboxed.Unsafe" #-}
834+
835+
pattern MV_5 :: Int -> MVector s a -> MVector s b -> MVector s c -> MVector s d
836+
-> MVector s e -> MVector s (a,b,c,d,e)
837+
pattern MV_5 i va vb vc vd ve = U.MV_5 i va vb vc vd ve
838+
{-# COMPLETE MV_5 #-}
839+
{-# DEPRECATED MV_5 "Import constructor from Data.Vector.Unboxed.Unsafe" #-}
840+
841+
pattern MV_6 :: Int -> MVector s a -> MVector s b -> MVector s c -> MVector s d
842+
-> MVector s e -> MVector s f -> MVector s (a,b,c,d,e,f)
843+
pattern MV_6 i va vb vc vd ve vf = U.MV_6 i va vb vc vd ve vf
844+
{-# COMPLETE MV_6 #-}
845+
{-# DEPRECATED MV_6 "Import constructor from Data.Vector.Unboxed.Unsafe" #-}

0 commit comments

Comments
 (0)