Skip to content

Commit 5125015

Browse files
committed
Replace exported constructors with deprecated pattern
1 parent da90e33 commit 5125015

File tree

8 files changed

+60
-14
lines changed

8 files changed

+60
-14
lines changed

vector/src/Data/Vector/Mutable.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{-# LANGUAGE MultiParamTypeClasses #-}
55
{-# LANGUAGE RoleAnnotations #-}
66
{-# LANGUAGE TypeFamilies #-}
7+
{-# LANGUAGE PatternSynonyms #-}
78
-- |
89
-- Module : Data.Vector.Mutable
910
-- Copyright : (c) Roman Leshchinskiy 2008-2010
@@ -20,7 +21,8 @@
2021

2122
module Data.Vector.Mutable (
2223
-- * Mutable boxed vectors
23-
MVector(MVector), IOVector, STVector,
24+
MVector, IOVector, STVector,
25+
pattern MVector,
2426

2527
-- * Accessors
2628

@@ -72,13 +74,19 @@ module Data.Vector.Mutable (
7274
) where
7375

7476
import qualified Data.Vector.Generic.Mutable as G
75-
import Data.Vector.Mutable.Unsafe
77+
import Data.Vector.Mutable.Unsafe (MVector,IOVector,STVector,toMutableArray,fromMutableArray)
78+
import qualified Data.Vector.Mutable.Unsafe as U
79+
import Data.Primitive.Array
7680
import Control.Monad.Primitive
7781

7882
import Prelude( Ord, Bool, Ordering(..), Int, Maybe )
7983

8084
#include "vector.h"
8185

86+
pattern MVector :: Int -> Int -> MutableArray s a -> MVector s a
87+
pattern MVector i j arr = U.MVector i j arr
88+
{-# COMPLETE MVector #-}
89+
{-# DEPRECATED MVector "Use constructor exported from Data.Vector.Mutable.Unsafe" #-}
8290

8391

8492
-- Length information

vector/src/Data/Vector/Primitive.hs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE RoleAnnotations #-}
66
{-# LANGUAGE ScopedTypeVariables #-}
77
{-# LANGUAGE TypeFamilies #-}
8+
{-# LANGUAGE PatternSynonyms #-}
89
-- |
910
-- Module : Data.Vector.Primitive
1011
-- Copyright : (c) Roman Leshchinskiy 2008-2010
@@ -24,7 +25,7 @@
2425

2526
module Data.Vector.Primitive (
2627
-- * Primitive vectors
27-
Vector(..), MVector(..),
28+
Vector, MVector, pattern MVector, pattern Vector,
2829

2930
-- * Accessors
3031

@@ -163,9 +164,12 @@ module Data.Vector.Primitive (
163164

164165
import Control.Applicative (Applicative)
165166
import qualified Data.Vector.Generic as G
166-
import Data.Vector.Primitive.Unsafe (Vector(..),unsafeCoerceVector,unsafeCast)
167-
import Data.Vector.Primitive.Mutable.Unsafe (MVector(..))
167+
import Data.Vector.Primitive.Unsafe (Vector,unsafeCoerceVector,unsafeCast)
168+
import qualified Data.Vector.Primitive.Unsafe as U
169+
import Data.Vector.Primitive.Mutable.Unsafe (MVector)
170+
import Data.Vector.Primitive.Mutable (pattern MVector)
168171
import Data.Primitive ( Prim )
172+
import Data.Primitive.ByteArray
169173

170174
import Control.Monad.ST ( ST )
171175
import Control.Monad.Primitive
@@ -174,6 +178,10 @@ import Prelude
174178
( Eq, Ord, Num, Enum, Monoid, Traversable, Monad, Bool, Ordering(..), Int, Maybe, Either
175179
, (==))
176180

181+
pattern Vector :: Int -> Int -> ByteArray -> Vector a
182+
pattern Vector i j arr = U.Vector i j arr
183+
{-# COMPLETE Vector #-}
184+
{-# DEPRECATED Vector "Use constructor exported from Data.Vector.Primitive.Unsafe" #-}
177185

178186
-- Length
179187
-- ------

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE MultiParamTypeClasses #-}
44
{-# LANGUAGE RoleAnnotations #-}
55
{-# LANGUAGE ScopedTypeVariables #-}
6+
{-# LANGUAGE PatternSynonyms #-}
67
-- |
78
-- Module : Data.Vector.Primitive.Mutable
89
-- Copyright : (c) Roman Leshchinskiy 2008-2010
@@ -19,7 +20,8 @@
1920

2021
module Data.Vector.Primitive.Mutable (
2122
-- * Mutable vectors of primitive types
22-
MVector(..), IOVector, STVector,
23+
MVector, IOVector, STVector,
24+
pattern MVector,
2325

2426
-- * Accessors
2527

@@ -71,14 +73,22 @@ module Data.Vector.Primitive.Mutable (
7173

7274
import qualified Data.Vector.Generic.Mutable as G
7375
import Data.Primitive ( Prim )
76+
import Data.Primitive.ByteArray
7477
import Data.Vector.Primitive.Mutable.Unsafe
7578
(MVector,IOVector,STVector,unsafeCoerceMVector,unsafeCast)
79+
import qualified Data.Vector.Primitive.Mutable.Unsafe as U
7680
import Control.Monad.Primitive
7781

7882
import Prelude ( Ord, Bool, Int, Maybe, Ordering(..) )
7983

8084
#include "vector.h"
8185

86+
87+
pattern MVector :: Int -> Int -> MutableByteArray s -> MVector s a
88+
pattern MVector i j arr = U.MVector i j arr
89+
{-# COMPLETE MVector #-}
90+
{-# DEPRECATED MVector "Use constructor exported from Data.Vector.Primitive.Mutable.Unsafe" #-}
91+
8292
-- Length information
8393
-- ------------------
8494

vector/src/Data/Vector/Storable.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE RoleAnnotations #-}
66
{-# LANGUAGE ScopedTypeVariables #-}
77
{-# LANGUAGE TypeFamilies #-}
8+
{-# LANGUAGE PatternSynonyms #-}
89
-- |
910
-- Module : Data.Vector.Storable
1011
-- Copyright : (c) Roman Leshchinskiy 2009-2010
@@ -21,7 +22,7 @@
2122

2223
module Data.Vector.Storable (
2324
-- * Storable vectors
24-
Vector, MVector(..),
25+
Vector, MVector, pattern MVector,
2526

2627
-- * Accessors
2728

@@ -169,7 +170,7 @@ module Data.Vector.Storable (
169170

170171
import Control.Applicative (Applicative)
171172
import qualified Data.Vector.Generic as G
172-
import Data.Vector.Storable.Mutable ( MVector(..) )
173+
import Data.Vector.Storable.Mutable ( MVector, pattern MVector )
173174
import Data.Vector.Storable.Unsafe
174175

175176
import Control.Monad.ST ( ST )

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{-# LANGUAGE MultiParamTypeClasses #-}
55
{-# LANGUAGE RoleAnnotations #-}
66
{-# LANGUAGE ScopedTypeVariables #-}
7+
{-# LANGUAGE PatternSynonyms #-}
78
-- |
89
-- Module : Data.Vector.Storable.Mutable
910
-- Copyright : (c) Roman Leshchinskiy 2009-2010
@@ -20,7 +21,8 @@
2021

2122
module Data.Vector.Storable.Mutable(
2223
-- * Mutable vectors of 'Storable' types
23-
MVector(..), IOVector, STVector,
24+
MVector, IOVector, STVector,
25+
pattern MVector,
2426

2527
-- * Accessors
2628

@@ -77,17 +79,25 @@ module Data.Vector.Storable.Mutable(
7779
) where
7880

7981
import qualified Data.Vector.Generic.Mutable as G
80-
import Data.Vector.Storable.Mutable.Unsafe
81-
82+
import Data.Vector.Storable.Mutable.Unsafe(
83+
MVector,IOVector,STVector,unsafeCast,unsafeWith,unsafeCoerceMVector,
84+
unsafeToForeignPtr,unsafeToForeignPtr0,unsafeFromForeignPtr,unsafeFromForeignPtr0)
85+
import qualified Data.Vector.Storable.Mutable.Unsafe as U
8286
import Foreign.Storable
8387

8488
import Control.Monad.Primitive
89+
import Foreign.ForeignPtr (ForeignPtr)
8590

8691
import Prelude (Int, Ord, Bool, Maybe, Ordering(..) )
8792

8893
#include "vector.h"
8994

9095

96+
pattern MVector :: Int -> ForeignPtr a -> MVector s a
97+
pattern MVector i ptr = U.MVector i ptr
98+
{-# COMPLETE MVector #-}
99+
{-# DEPRECATED MVector "Use constructor exported from Data.Vector.Strict.Mutable.Unsafe" #-}
100+
91101

92102
-- Length information
93103
-- ------------------

vector/src/Data/Vector/Storable/Unsafe.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Data.Vector.Storable.Unsafe
1616
) where
1717

1818
import qualified Data.Vector.Generic as G
19-
import Data.Vector.Storable.Mutable ( MVector(..) )
19+
import Data.Vector.Storable.Mutable.Unsafe ( MVector(..) )
2020
import Data.Vector.Storable.Internal
2121
import qualified Data.Vector.Fusion.Bundle as Bundle
2222

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{-# LANGUAGE TypeFamilies #-}
77
{-# LANGUAGE TypeApplications #-}
88
{-# LANGUAGE ScopedTypeVariables #-}
9+
{-# LANGUAGE PatternSynonyms #-}
910
-- |
1011
-- Module : Data.Vector.Strict.Mutable
1112
-- Copyright : (c) Roman Leshchinskiy 2008-2010
@@ -24,7 +25,8 @@
2425
-- are set to ⊥.
2526
module Data.Vector.Strict.Mutable (
2627
-- * Mutable boxed vectors
27-
MVector(MVector), IOVector, STVector,
28+
MVector, IOVector, STVector,
29+
pattern MVector,
2830

2931
-- * Accessors
3032

@@ -77,13 +79,20 @@ module Data.Vector.Strict.Mutable (
7779
) where
7880

7981
import qualified Data.Vector.Generic.Mutable as G
82+
import qualified Data.Vector.Mutable as MV
8083
import Data.Vector.Strict.Mutable.Unsafe
84+
(MVector,IOVector,STVector,toLazy,fromLazy,toMutableArray,fromMutableArray)
85+
import qualified Data.Vector.Strict.Mutable.Unsafe as U
8186
import Control.Monad.Primitive
8287

8388
import Prelude ( Ord, Bool, Int, Maybe, Ordering(..))
8489

8590
#include "vector.h"
8691

92+
pattern MVector :: MV.MVector s a -> MVector s a
93+
pattern MVector v = U.MVector v
94+
{-# COMPLETE MVector #-}
95+
{-# DEPRECATED MVector "Use constructor exported from Data.Vector.Strict.Unsafe" #-}
8796

8897

8998
-- Length information

vector/src/Data/Vector/Strict/Unsafe.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Data.Vector.Strict.Unsafe
2222

2323

2424
import Data.Coerce
25-
import Data.Vector.Strict.Mutable ( MVector(..) )
25+
import Data.Vector.Strict.Mutable.Unsafe ( MVector(..) )
2626
import Data.Primitive.Array
2727
import qualified Data.Vector.Generic as G
2828
import Data.Vector.Generic ((!))

0 commit comments

Comments
 (0)