diff options
| author | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2026-04-04 16:26:06 +0200 |
|---|---|---|
| committer | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2026-04-04 20:52:32 +0200 |
| commit | ee319119b1f24db2b2e981e303db9935a1dca425 (patch) | |
| tree | 818218affd29d640b7842c8ef668964f556a30c7 /src/Data/Array/Nested/Mixed | |
| parent | 53bc096c807fc63cfe5f1102131b475deb5e21ca (diff) | |
Remove copies of length and toList operations that Foldable already provides
in preparation for deriving Foldable for []
Diffstat (limited to 'src/Data/Array/Nested/Mixed')
| -rw-r--r-- | src/Data/Array/Nested/Mixed/Shape.hs | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/src/Data/Array/Nested/Mixed/Shape.hs b/src/Data/Array/Nested/Mixed/Shape.hs index 5887f4e..2dfcc8c 100644 --- a/src/Data/Array/Nested/Mixed/Shape.hs +++ b/src/Data/Array/Nested/Mixed/Shape.hs @@ -87,13 +87,9 @@ instance Foldable (ListX l) where {-# INLINE foldr #-} foldr _ z ZX = z foldr f z (x ::% xs) = f x (foldr f z xs) - toList = listxToList null ZX = False null _ = True -listxLength :: ListX sh i -> Int -listxLength = length - listxRank :: ListX sh i -> SNat (Rank sh) listxRank ZX = SNat listxRank (_ ::% l) | SNat <- listxRank l = SNat @@ -116,14 +112,6 @@ listxFromList topssh topl = go topssh topl ++ show (ssxLength topssh) ++ ", list has length " ++ show (length topl) ++ ")" -{-# INLINEABLE listxToList #-} -listxToList :: ListX sh i -> [i] -listxToList list = build (\(cons :: i -> is -> is) (nil :: is) -> - let go :: ListX sh i -> is - go ZX = nil - go (i ::% is) = i `cons` go is - in go list) - listxHead :: ListX (mn ': sh) i -> i listxHead (i ::% _) = i @@ -184,9 +172,6 @@ instance Show i => Show (IxX sh i) where showsPrec _ (IxX l) = listxShow shows l #endif -ixxLength :: IxX sh i -> Int -ixxLength (IxX l) = listxLength l - ixxRank :: IxX sh i -> SNat (Rank sh) ixxRank (IxX l) = listxRank l @@ -202,9 +187,6 @@ ixxZero' (_ :$% sh) = 0 :.% ixxZero' sh ixxFromList :: forall sh i. StaticShX sh -> [i] -> IxX sh i ixxFromList = coerce (listxFromList @_ @i) -ixxToList :: IxX sh i -> [i] -ixxToList = Foldable.toList - ixxHead :: IxX (n : sh) i -> i ixxHead (IxX list) = listxHead list @@ -794,7 +776,7 @@ shxFlatten = go (SNat @1) instance KnownShX sh => IsList (ListX sh i) where type Item (ListX sh i) = i fromList = listxFromList (knownShX @sh) - toList = listxToList + toList = Foldable.toList -- | Very untyped: only length is checked (at runtime), index bounds are __not checked__. instance KnownShX sh => IsList (IxX sh i) where |
