diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-06-14 10:08:03 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-06-14 10:08:03 +0200 |
commit | 22f8f053f9ea2a3273d25f49ecd88a30ad506972 (patch) | |
tree | da1b7879fbb87479874490d5a2d2680a7979f593 /src/Data/Array/Nested/Internal/Shape.hs | |
parent | c6b912051ddac25c9d7efe2f8162eac9068a335c (diff) |
Export full [mrs]{shape,rank,size} set
Diffstat (limited to 'src/Data/Array/Nested/Internal/Shape.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal/Shape.hs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Data/Array/Nested/Internal/Shape.hs b/src/Data/Array/Nested/Internal/Shape.hs index f449536..ca04840 100644 --- a/src/Data/Array/Nested/Internal/Shape.hs +++ b/src/Data/Array/Nested/Internal/Shape.hs @@ -94,7 +94,7 @@ listrIndex _ ZR = error "k + 1 <= 0" listrRank :: ListR n i -> SNat n listrRank ZR = SNat -listrRank (_ ::: (sh :: ListR n i)) = snatSucc (listrRank sh) +listrRank (_ ::: sh) = snatSucc (listrRank sh) listrPermutePrefix :: forall i n. [Int] -> ListR n i -> ListR n i listrPermutePrefix = \perm sh -> @@ -320,6 +320,10 @@ listsAppend :: ListS sh f -> ListS sh' f -> ListS (sh ++ sh') f listsAppend ZS idx' = idx' listsAppend (i ::$ idx) idx' = i ::$ listsAppend idx idx' +listsRank :: ListS sh i -> SNat (Rank sh) +listsRank ZS = SNat +listsRank (_ ::$ sh) = snatSucc (listsRank sh) + listsTakeLenPerm :: forall f is sh. Perm is -> ListS sh f -> ListS (TakeLen is sh) f listsTakeLenPerm PNil _ = ZS listsTakeLenPerm (_ `PCons` is) (n ::$ sh) = n ::$ listsTakeLenPerm is sh @@ -435,6 +439,9 @@ instance Show (ShS sh) where shsLength :: ShS sh -> Int shsLength (ShS l) = getSum (listsFold (\_ -> Sum 1) l) +shsRank :: ShS sh -> SNat (Rank sh) +shsRank (ShS l) = listsRank l + shsToList :: ShS sh -> [Int] shsToList ZSS = [] shsToList (sn :$$ sh) = fromSNat' sn : shsToList sh |