Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate sequenceA #29

Merged
merged 3 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions fixed-vector/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Changes in 1.3.0.0
* `Data.Vector.Fixed.Storable.unsafeWith` ensures that pointer won't
get GC'd while function runs

* `Data.Vector.Fixed.sequenceA` is deprecated in favor of `sequence`


Changes in 1.2.3.0

* Pattern `V1` added
Expand Down
7 changes: 4 additions & 3 deletions fixed-vector/Data/Vector/Fixed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ module Data.Vector.Fixed (
, scanl1
, sequence
, sequence_
, sequenceA
, traverse
, distribute
, collect
Expand Down Expand Up @@ -184,6 +183,8 @@ module Data.Vector.Fixed (
, defaultPoke
-- ** NFData
, defaultRnf
-- * Deprecated functions
, sequenceA
) where

import Control.Applicative (Applicative(..))
Expand Down Expand Up @@ -284,7 +285,7 @@ deriving via ViaFixed (VecList n) instance (Arity n) => Applicative (VecList n)
deriving via ViaFixed (VecList n) instance (Arity n) => F.Foldable (VecList n)

instance Arity n => T.Traversable (VecList n) where
sequenceA = sequenceA
sequenceA = sequence
traverse = traverse

deriving via ViaFixed (VecList n) a instance (Arity n, Show a) => Show (VecList n a)
Expand All @@ -302,7 +303,7 @@ deriving via ViaFixed (VecPeano n) instance (ArityPeano n) => Applicative (VecPe
deriving via ViaFixed (VecPeano n) instance (ArityPeano n) => F.Foldable (VecPeano n)

instance ArityPeano n => T.Traversable (VecPeano n) where
sequenceA = sequenceA
sequenceA = sequence
traverse = traverse

deriving via ViaFixed (VecPeano n) a instance (ArityPeano n, Show a) => Show (VecPeano n a)
Expand Down
2 changes: 1 addition & 1 deletion fixed-vector/Data/Vector/Fixed/Boxed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ deriving via ViaFixed (Vec n) instance Arity n => Applicative (Vec n)
deriving via ViaFixed (Vec n) instance Arity n => F.Foldable (Vec n)

instance Arity n => T.Traversable (Vec n) where
sequenceA = sequenceA
sequenceA = sequence
traverse = traverse
{-# INLINE sequenceA #-}
{-# INLINE traverse #-}
Expand Down
25 changes: 11 additions & 14 deletions fixed-vector/Data/Vector/Fixed/Cont.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ import qualified Data.Traversable as F
import Unsafe.Coerce (unsafeCoerce)
import GHC.TypeLits
import GHC.Exts (Proxy#, proxy#)
import Prelude hiding ( replicate,map,zipWith,zipWith3,maximum,minimum,and,or,any,all
, foldl,foldr,foldl1,length,sum,reverse,scanl,scanl1
, head,tail,mapM,mapM_,sequence,sequence_,concat
import Prelude ( Bool(..), Int, Maybe(..), Either(..)
, Eq(..), Ord(..), Num(..), Functor(..), Applicative(..), Monad(..)
, Semigroup(..), Monoid(..)
, (.), ($), (&&), (||), (<$>), const, id, flip, error, otherwise, fst, maybe
)


Expand Down Expand Up @@ -508,18 +509,14 @@ instance (ArityPeano n) => F.Foldable (ContVec n) where
{-# INLINE foldr #-}

instance (ArityPeano n) => F.Traversable (ContVec n) where
sequenceA v = inspect v $ sequenceAF construct
sequence = sequence
sequenceA = sequence
traverse = mapM
mapM = mapM
{-# INLINE sequence #-}
{-# INLINE sequenceA #-}

sequenceAF :: forall f n a b. (Applicative f, ArityPeano n)
=> Fun n a b -> Fun n (f a) (f b)
{-# INLINE sequenceAF #-}
sequenceAF (Fun f0)
= accum (\(T_sequenceA f) a -> T_sequenceA (f <*> a))
(\(T_sequenceA f) -> f)
(T_sequenceA (pure f0) :: T_sequenceA f a b n)

newtype T_sequenceA f a b n = T_sequenceA (f (Fn n a b))
{-# INLINE mapM #-}
{-# INLINE traverse #-}



Expand Down
3 changes: 2 additions & 1 deletion fixed-vector/Data/Vector/Fixed/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,8 @@ scanl1 f = vector . C.scanl1 f . C.cvec
sequenceA :: (Vector v a, Vector v (f a), Applicative f)
=> v (f a) -> f (v a)
{-# INLINE sequenceA #-}
sequenceA = fmap vector . T.sequenceA . C.cvec
sequenceA = sequence
{-# DEPRECATED sequenceA "Use sequence instead" #-}

-- | Analog of 'T.traverse' from 'T.Traversable'.
traverse :: (Vector v a, Vector v b, Applicative f)
Expand Down
2 changes: 1 addition & 1 deletion fixed-vector/Data/Vector/Fixed/Strict.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ deriving via ViaFixed (Vec n) instance Arity n => Applicative (Vec n)
deriving via ViaFixed (Vec n) instance Arity n => F.Foldable (Vec n)

instance Arity n => T.Traversable (Vec n) where
sequenceA = sequenceA
sequenceA = sequence
traverse = traverse
{-# INLINE sequenceA #-}
{-# INLINE traverse #-}
Expand Down
Loading