diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2025-12-02 15:01:26 +0100 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2025-12-02 15:01:26 +0100 |
| commit | f76d781c75105b7b04ed2e602f0139d35846ab92 (patch) | |
| tree | 2ae7357a52f8c2e302332cd8d7754c23fe5be511 /src/Data/Array/Nested/Shaped/Shape.hs | |
| parent | 9f47aa6a2bcd772388a5d5150ca7254e4eb95bc2 (diff) | |
Style and uniformity of shape/index/list functions
Diffstat (limited to 'src/Data/Array/Nested/Shaped/Shape.hs')
| -rw-r--r-- | src/Data/Array/Nested/Shaped/Shape.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Data/Array/Nested/Shaped/Shape.hs b/src/Data/Array/Nested/Shaped/Shape.hs index eb8653d..0a4c1b9 100644 --- a/src/Data/Array/Nested/Shaped/Shape.hs +++ b/src/Data/Array/Nested/Shaped/Shape.hs @@ -237,9 +237,7 @@ instance Foldable (IxS sh) where {-# INLINE foldr #-} foldr _ z ZIS = z foldr f z (x :.$ xs) = f x (foldr f z xs) - {-# INLINEABLE toList #-} - toList ZIS = [] - toList (i :.$ is) = i : Foldable.toList is + toList = ixsToList null ZIS = False null _ = True @@ -254,6 +252,9 @@ ixsRank (IxS l) = listsRank l ixsFromList :: forall sh i. ShS sh -> [i] -> IxS sh i ixsFromList = coerce (listsFromList @_ @i) +ixsToList :: forall sh i. IxS sh i -> [i] +ixsToList = coerce (listsToList @_ @i) + ixsZero :: ShS sh -> IIxS sh ixsZero ZSS = ZIS ixsZero (_ :$$ sh) = 0 :.$ ixsZero sh @@ -349,7 +350,7 @@ shsSize :: ShS sh -> Int shsSize ZSS = 1 shsSize (n :$$ sh) = fromSNat' n * shsSize sh --- This is a partial @const@ that fails when the second argument +-- | This is a partial @const@ that fails when the second argument -- doesn't match the first. shsFromList :: ShS sh -> [Int] -> ShS sh shsFromList sh0@ZSS [] = sh0 |
