aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-05-14 10:43:06 +0200
committerTom Smeding <tom@tomsmeding.com>2024-05-14 10:43:06 +0200
commitf5bc67f8530c50f90692824192d7dfb81ba1b334 (patch)
tree1cf6f0ecdbbaa9aaa6be6665df9bf8355af952c9 /src/Data/Array/Nested
parent172925e245728efb50d692c2f7460fd3e5f6dca2 (diff)
Better {from,to}List{,1} names
Diffstat (limited to 'src/Data/Array/Nested')
-rw-r--r--src/Data/Array/Nested/Internal.hs82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs
index 3084e98..d75aeaf 100644
--- a/src/Data/Array/Nested/Internal.hs
+++ b/src/Data/Array/Nested/Internal.hs
@@ -240,9 +240,9 @@ class Elt a where
--
-- If you want a single-dimensional array from your list, map 'mscalar'
-- first.
- mfromList :: forall n sh. KnownShapeX (n : sh) => NonEmpty (Mixed sh a) -> Mixed (n : sh) a
+ mfromList1 :: forall n sh. KnownShapeX (n : sh) => NonEmpty (Mixed sh a) -> Mixed (n : sh) a
- mtoList :: Mixed (n : sh) a -> [Mixed sh a]
+ mtoList1 :: Mixed (n : sh) a -> [Mixed sh a]
-- | Note: this library makes no particular guarantees about the shapes of
-- arrays "inside" an empty array. With 'mlift' and 'mlift2' you can see the
@@ -295,8 +295,8 @@ instance Storable a => Elt (Primitive a) where
mindex (M_Primitive a) i = Primitive (X.index a i)
mindexPartial (M_Primitive a) i = M_Primitive (X.indexPartial a i)
mscalar (Primitive x) = M_Primitive (X.scalar x)
- mfromList l = M_Primitive (X.fromList knownShapeX (coerce (toList l)))
- mtoList (M_Primitive arr) = coerce (X.toList arr)
+ mfromList1 l = M_Primitive (X.fromList1 knownShapeX (coerce (toList l)))
+ mtoList1 (M_Primitive arr) = coerce (X.toList1 arr)
mlift :: forall sh1 sh2.
(Proxy '[] -> XArray (sh1 ++ '[]) a -> XArray (sh2 ++ '[]) a)
@@ -345,9 +345,9 @@ instance (Elt a, Elt b) => Elt (a, b) where
mindex (M_Tup2 a b) i = (mindex a i, mindex b i)
mindexPartial (M_Tup2 a b) i = M_Tup2 (mindexPartial a i) (mindexPartial b i)
mscalar (x, y) = M_Tup2 (mscalar x) (mscalar y)
- mfromList l = M_Tup2 (mfromList ((\(M_Tup2 x _) -> x) <$> l))
- (mfromList ((\(M_Tup2 _ y) -> y) <$> l))
- mtoList (M_Tup2 a b) = zipWith M_Tup2 (mtoList a) (mtoList b)
+ mfromList1 l = M_Tup2 (mfromList1 ((\(M_Tup2 x _) -> x) <$> l))
+ (mfromList1 ((\(M_Tup2 _ y) -> y) <$> l))
+ mtoList1 (M_Tup2 a b) = zipWith M_Tup2 (mtoList1 a) (mtoList1 b)
mlift f (M_Tup2 a b) = M_Tup2 (mlift f a) (mlift f b)
mlift2 f (M_Tup2 a b) (M_Tup2 x y) = M_Tup2 (mlift2 f a x) (mlift2 f b y)
@@ -386,13 +386,13 @@ instance (Elt a, KnownShapeX sh') => Elt (Mixed sh' a) where
mscalar = M_Nest
- mfromList :: forall n sh. KnownShapeX (n : sh)
- => NonEmpty (Mixed sh (Mixed sh' a)) -> Mixed (n : sh) (Mixed sh' a)
- mfromList l
+ mfromList1 :: forall n sh. KnownShapeX (n : sh)
+ => NonEmpty (Mixed sh (Mixed sh' a)) -> Mixed (n : sh) (Mixed sh' a)
+ mfromList1 l
| Dict <- X.lemKnownShapeX (X.ssxAppend (knownShapeX @(n : sh)) (knownShapeX @sh'))
- = M_Nest (mfromList (coerce l))
+ = M_Nest (mfromList1 (coerce l))
- mtoList (M_Nest arr) = coerce (mtoList arr)
+ mtoList1 (M_Nest arr) = coerce (mtoList1 arr)
mlift :: forall sh1 sh2. KnownShapeX sh2
=> (forall shT b. (KnownShapeX shT, Storable b) => Proxy shT -> XArray (sh1 ++ shT) b -> XArray (sh2 ++ shT) b)
@@ -518,11 +518,11 @@ mtoVectorP (M_Primitive v) = X.toVector v
mtoVector :: (Storable a, PrimElt a) => Mixed sh a -> VS.Vector a
mtoVector arr = mtoVectorP (coerce toPrimitive arr)
-mfromList1 :: (KnownShapeX '[n], Elt a) => NonEmpty a -> Mixed '[n] a
-mfromList1 = mfromList . fmap mscalar
+mfromList :: (KnownShapeX '[n], Elt a) => NonEmpty a -> Mixed '[n] a
+mfromList = mfromList1 . fmap mscalar
-mtoList1 :: Elt a => Mixed '[n] a -> [a]
-mtoList1 = map munScalar . mtoList
+mtoList :: Elt a => Mixed '[n] a -> [a]
+mtoList = map munScalar . mtoList1
munScalar :: Elt a => Mixed '[] a -> a
munScalar arr = mindex arr ZIX
@@ -620,16 +620,16 @@ instance (Elt a, KnownINat n) => Elt (Ranked n a) where
mscalar (Ranked x) = M_Ranked (M_Nest x)
- mfromList :: forall m sh. KnownShapeX (m : sh)
- => NonEmpty (Mixed sh (Ranked n a)) -> Mixed (m : sh) (Ranked n a)
- mfromList l
+ mfromList1 :: forall m sh. KnownShapeX (m : sh)
+ => NonEmpty (Mixed sh (Ranked n a)) -> Mixed (m : sh) (Ranked n a)
+ mfromList1 l
| Dict <- lemKnownReplicate (Proxy @n)
- = M_Ranked (mfromList (coerce l))
+ = M_Ranked (mfromList1 (coerce l))
- mtoList :: forall m sh. Mixed (m : sh) (Ranked n a) -> [Mixed sh (Ranked n a)]
- mtoList (M_Ranked arr)
+ mtoList1 :: forall m sh. Mixed (m : sh) (Ranked n a) -> [Mixed sh (Ranked n a)]
+ mtoList1 (M_Ranked arr)
| Dict <- lemKnownReplicate (Proxy @n)
- = coerce @[Mixed sh (Mixed (Replicate n 'Nothing) a)] @[Mixed sh (Ranked n a)] (mtoList arr)
+ = coerce @[Mixed sh (Mixed (Replicate n 'Nothing) a)] @[Mixed sh (Ranked n a)] (mtoList1 arr)
mlift :: forall sh1 sh2. KnownShapeX sh2
=> (forall sh' b. (KnownShapeX sh', Storable b) => Proxy sh' -> XArray (sh1 ++ sh') b -> XArray (sh2 ++ sh') b)
@@ -749,16 +749,16 @@ instance (Elt a, KnownShape sh) => Elt (Shaped sh a) where
mscalar (Shaped x) = M_Shaped (M_Nest x)
- mfromList :: forall n sh'. KnownShapeX (n : sh')
- => NonEmpty (Mixed sh' (Shaped sh a)) -> Mixed (n : sh') (Shaped sh a)
- mfromList l
+ mfromList1 :: forall n sh'. KnownShapeX (n : sh')
+ => NonEmpty (Mixed sh' (Shaped sh a)) -> Mixed (n : sh') (Shaped sh a)
+ mfromList1 l
| Dict <- lemKnownMapJust (Proxy @sh)
- = M_Shaped (mfromList (coerce l))
+ = M_Shaped (mfromList1 (coerce l))
- mtoList :: forall n sh'. Mixed (n : sh') (Shaped sh a) -> [Mixed sh' (Shaped sh a)]
- mtoList (M_Shaped arr)
+ mtoList1 :: forall n sh'. Mixed (n : sh') (Shaped sh a) -> [Mixed sh' (Shaped sh a)]
+ mtoList1 (M_Shaped arr)
| Dict <- lemKnownMapJust (Proxy @sh)
- = coerce @[Mixed sh' (Mixed (MapJust sh) a)] @[Mixed sh' (Shaped sh a)] (mtoList arr)
+ = coerce @[Mixed sh' (Mixed (MapJust sh) a)] @[Mixed sh' (Shaped sh a)] (mtoList1 arr)
mlift :: forall sh1 sh2. KnownShapeX sh2
=> (forall sh' b. (KnownShapeX sh', Storable b) => Proxy sh' -> XArray (sh1 ++ sh') b -> XArray (sh2 ++ sh') b)
@@ -1048,16 +1048,16 @@ rtoVectorP = coerce mtoVectorP
rtoVector :: (Storable a, PrimElt a) => Ranked n a -> VS.Vector a
rtoVector = coerce mtoVector
-rfromList :: forall n a. (KnownINat n, Elt a) => NonEmpty (Ranked n a) -> Ranked (S n) a
-rfromList l
+rfromList1 :: forall n a. (KnownINat n, Elt a) => NonEmpty (Ranked n a) -> Ranked (S n) a
+rfromList1 l
| Dict <- lemKnownReplicate (Proxy @n)
= Ranked (mfromList ((\(Ranked x) -> x) <$> l))
-rfromList1 :: Elt a => NonEmpty a -> Ranked I1 a
-rfromList1 = Ranked . mfromList . fmap mscalar
+rfromList :: Elt a => NonEmpty a -> Ranked I1 a
+rfromList = Ranked . mfromList1 . fmap mscalar
rtoList :: Elt a => Ranked (S n) a -> [Ranked n a]
-rtoList (Ranked arr) = coerce (mtoList arr)
+rtoList (Ranked arr) = coerce (mtoList1 arr)
rtoList1 :: Elt a => Ranked I1 a -> [a]
rtoList1 = map runScalar . rtoList
@@ -1254,17 +1254,17 @@ stoVectorP = coerce mtoVectorP
stoVector :: (Storable a, PrimElt a) => Shaped sh a -> VS.Vector a
stoVector = coerce mtoVector
-sfromList :: forall n sh a. (KnownNat n, KnownShape sh, Elt a)
- => NonEmpty (Shaped sh a) -> Shaped (n : sh) a
-sfromList l
+sfromList1 :: forall n sh a. (KnownNat n, KnownShape sh, Elt a)
+ => NonEmpty (Shaped sh a) -> Shaped (n : sh) a
+sfromList1 l
| Dict <- lemKnownMapJust (Proxy @sh)
= Shaped (mfromList ((\(Shaped x) -> x) <$> l))
-sfromList1 :: (KnownNat n, Elt a) => NonEmpty a -> Shaped '[n] a
-sfromList1 = Shaped . mfromList . fmap mscalar
+sfromList :: (KnownNat n, Elt a) => NonEmpty a -> Shaped '[n] a
+sfromList = Shaped . mfromList1 . fmap mscalar
stoList :: Elt a => Shaped (n : sh) a -> [Shaped sh a]
-stoList (Shaped arr) = coerce (mtoList arr)
+stoList (Shaped arr) = coerce (mtoList1 arr)
stoList1 :: Elt a => Shaped '[n] a -> [a]
stoList1 = map sunScalar . stoList