diff options
Diffstat (limited to 'src/Data/Array/Nested/Permutation.hs')
| -rw-r--r-- | src/Data/Array/Nested/Permutation.hs | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/Data/Array/Nested/Permutation.hs b/src/Data/Array/Nested/Permutation.hs index f4ce90b..d2557b6 100644 --- a/src/Data/Array/Nested/Permutation.hs +++ b/src/Data/Array/Nested/Permutation.hs @@ -171,17 +171,17 @@ type family DropLen ref l where DropLen '[] l = l DropLen (_ : ref) (_ : xs) = DropLen ref xs -listhTakeLen :: forall i is sh. Perm is -> ListH sh i -> ListH (TakeLen is sh) i -listhTakeLen PNil _ = ZH -listhTakeLen (_ `PCons` is) (n `ConsUnknown` sh) = n `ConsUnknown` listhTakeLen is sh -listhTakeLen (_ `PCons` is) (n `ConsKnown` sh) = n `ConsKnown` listhTakeLen is sh -listhTakeLen (_ `PCons` _) ZH = error "Permutation longer than shape" +listhTakeLenPerm :: forall i is sh. Perm is -> ListH sh i -> ListH (TakeLen is sh) i +listhTakeLenPerm PNil _ = ZH +listhTakeLenPerm (_ `PCons` is) (n `ConsUnknown` sh) = n `ConsUnknown` listhTakeLenPerm is sh +listhTakeLenPerm (_ `PCons` is) (n `ConsKnown` sh) = n `ConsKnown` listhTakeLenPerm is sh +listhTakeLenPerm (_ `PCons` _) ZH = error "Permutation longer than shape" -listhDropLen :: forall i is sh. Perm is -> ListH sh i -> ListH (DropLen is sh) i -listhDropLen PNil sh = sh -listhDropLen (_ `PCons` is) (_ `ConsUnknown` sh) = listhDropLen is sh -listhDropLen (_ `PCons` is) (_ `ConsKnown` sh) = listhDropLen is sh -listhDropLen (_ `PCons` _) ZH = error "Permutation longer than shape" +listhDropLenPerm :: forall i is sh. Perm is -> ListH sh i -> ListH (DropLen is sh) i +listhDropLenPerm PNil sh = sh +listhDropLenPerm (_ `PCons` is) (_ `ConsUnknown` sh) = listhDropLenPerm is sh +listhDropLenPerm (_ `PCons` is) (_ `ConsKnown` sh) = listhDropLenPerm is sh +listhDropLenPerm (_ `PCons` _) ZH = error "Permutation longer than shape" listhPermute :: forall i is sh. Perm is -> ListH sh i -> ListH (Permute is sh) i listhPermute PNil _ = ZH @@ -202,13 +202,13 @@ listhIndex (SS (i :: SNat k')) ((_ :: SNat n) `ConsKnown` (sh :: ListH sh' i)) listhIndex _ ZH = error "Index into empty shape" listhPermutePrefix :: forall i is sh. Perm is -> ListH sh i -> ListH (PermutePrefix is sh) i -listhPermutePrefix perm sh = listhAppend (listhPermute perm (listhTakeLen perm sh)) (listhDropLen perm sh) +listhPermutePrefix perm sh = listhAppend (listhPermute perm (listhTakeLenPerm perm sh)) (listhDropLenPerm perm sh) -ssxTakeLen :: forall is sh. Perm is -> StaticShX sh -> StaticShX (TakeLen is sh) -ssxTakeLen = coerce (listhTakeLen @()) +ssxTakeLenPerm :: forall is sh. Perm is -> StaticShX sh -> StaticShX (TakeLen is sh) +ssxTakeLenPerm = coerce (listhTakeLenPerm @()) -ssxDropLen :: Perm is -> StaticShX sh -> StaticShX (DropLen is sh) -ssxDropLen = coerce (listhDropLen @()) +ssxDropLenPerm :: Perm is -> StaticShX sh -> StaticShX (DropLen is sh) +ssxDropLenPerm = coerce (listhDropLenPerm @()) ssxPermute :: Perm is -> StaticShX sh -> StaticShX (Permute is sh) ssxPermute = coerce (listhPermute @()) @@ -219,11 +219,11 @@ ssxIndex k = coerce (listhIndex @() k) ssxPermutePrefix :: Perm is -> StaticShX sh -> StaticShX (PermutePrefix is sh) ssxPermutePrefix = coerce (listhPermutePrefix @()) -shxTakeLen :: forall is sh. Perm is -> IShX sh -> IShX (TakeLen is sh) -shxTakeLen = coerce (listhTakeLen @Int) +shxTakeLenPerm :: forall is sh. Perm is -> IShX sh -> IShX (TakeLen is sh) +shxTakeLenPerm = coerce (listhTakeLenPerm @Int) -shxDropLen :: Perm is -> IShX sh -> IShX (DropLen is sh) -shxDropLen = coerce (listhDropLen @Int) +shxDropLenPerm :: Perm is -> IShX sh -> IShX (DropLen is sh) +shxDropLenPerm = coerce (listhDropLenPerm @Int) shxPermute :: Perm is -> IShX sh -> IShX (Permute is sh) shxPermute = coerce (listhPermute @Int) @@ -235,15 +235,15 @@ shxPermutePrefix :: Perm is -> IShX sh -> IShX (PermutePrefix is sh) shxPermutePrefix = coerce (listhPermutePrefix @Int) -listxTakeLen :: forall i is sh. Perm is -> ListX sh i -> ListX (TakeLen is sh) i -listxTakeLen PNil _ = ZX -listxTakeLen (_ `PCons` is) (n ::% sh) = n ::% listxTakeLen is sh -listxTakeLen (_ `PCons` _) ZX = error "Permutation longer than shape" +listxTakeLenPerm :: forall i is sh. Perm is -> ListX sh i -> ListX (TakeLen is sh) i +listxTakeLenPerm PNil _ = ZX +listxTakeLenPerm (_ `PCons` is) (n ::% sh) = n ::% listxTakeLenPerm is sh +listxTakeLenPerm (_ `PCons` _) ZX = error "Permutation longer than shape" -listxDropLen :: forall i is sh. Perm is -> ListX sh i -> ListX (DropLen is sh) i -listxDropLen PNil sh = sh -listxDropLen (_ `PCons` is) (_ ::% sh) = listxDropLen is sh -listxDropLen (_ `PCons` _) ZX = error "Permutation longer than shape" +listxDropLenPerm :: forall i is sh. Perm is -> ListX sh i -> ListX (DropLen is sh) i +listxDropLenPerm PNil sh = sh +listxDropLenPerm (_ `PCons` is) (_ ::% sh) = listxDropLenPerm is sh +listxDropLenPerm (_ `PCons` _) ZX = error "Permutation longer than shape" listxPermute :: forall i is sh. Perm is -> ListX sh i -> ListX (Permute is sh) i listxPermute PNil _ = ZX @@ -256,7 +256,7 @@ listxIndex (SS i) (_ ::% sh) = listxIndex i sh listxIndex _ ZX = error "Index into empty shape" listxPermutePrefix :: forall i is sh. Perm is -> ListX sh i -> ListX (PermutePrefix is sh) i -listxPermutePrefix perm sh = listxAppend (listxPermute perm (listxTakeLen perm sh)) (listxDropLen perm sh) +listxPermutePrefix perm sh = listxAppend (listxPermute perm (listxTakeLenPerm perm sh)) (listxDropLenPerm perm sh) ixxPermutePrefix :: forall i is sh. Perm is -> IxX sh i -> IxX (PermutePrefix is sh) i ixxPermutePrefix = coerce (listxPermutePrefix @i) |
