aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Shaped/Shape.hs
diff options
context:
space:
mode:
authorMikolaj Konarski <mikolaj.konarski@funktory.com>2026-04-09 17:48:51 +0200
committerMikolaj Konarski <mikolaj.konarski@funktory.com>2026-04-09 18:38:41 +0200
commit27f5fd474a85bd0c404215a1ce38ed378594e54b (patch)
tree6a6440ae6436d9013079a422962d5a48d3095242 /src/Data/Array/Nested/Shaped/Shape.hs
parentf56ba83f256808b92284f2d3c6440bda398ee304 (diff)
Get rid of ListH
Diffstat (limited to 'src/Data/Array/Nested/Shaped/Shape.hs')
-rw-r--r--src/Data/Array/Nested/Shaped/Shape.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/Data/Array/Nested/Shaped/Shape.hs b/src/Data/Array/Nested/Shaped/Shape.hs
index 622ab97..3d4bf31 100644
--- a/src/Data/Array/Nested/Shaped/Shape.hs
+++ b/src/Data/Array/Nested/Shaped/Shape.hs
@@ -326,23 +326,23 @@ shsSize (ShS sh) = shxSize sh
-- in case of errors in order not to retain the list.
{-# INLINEABLE shsFromList #-}
shsFromList :: ShS sh -> [Int] -> ShS sh
-shsFromList sh0@(ShS (ShX topsh)) topl = go topsh topl `seq` sh0
+shsFromList sh0@(ShS topsh) topl = go topsh topl `seq` sh0
where
- go :: ListH sh' Int -> [Int] -> ()
- go ZH [] = ()
- go ZH _ = error $ "shsFromList: List too long (type says " ++ show (listhLength topsh) ++ ")"
+ go :: ShX sh' Int -> [Int] -> ()
+ go ZSX [] = ()
+ go ZSX _ = error $ "shsFromList: List too long (type says " ++ show (shxLength topsh) ++ ")"
go (ConsKnown sn sh) (i : is)
| i == fromSNat' sn = go sh is
| otherwise = error "shsFromList: Value does not match typing"
go ConsUnknown{} _ = error "shsFromList: impossible case"
- go _ _ = error $ "shsFromList: List too short (type says " ++ show (listhLength topsh) ++ ")"
+ go _ _ = error $ "shsFromList: List too short (type says " ++ show (shxLength topsh) ++ ")"
-- This is equivalent to but faster than @coerce shxToList@.
{-# INLINEABLE shsToList #-}
shsToList :: ShS sh -> [Int]
-shsToList (ShS (ShX l)) = build (\(cons :: i -> is -> is) (nil :: is) ->
- let go :: ListH sh Int -> is
- go ZH = nil
+shsToList (ShS l) = build (\(cons :: i -> is -> is) (nil :: is) ->
+ let go :: ShX sh Int -> is
+ go ZSX = nil
go ConsUnknown{} = error "shsToList: impossible case"
go (ConsKnown snat rest) = fromSNat' snat `cons` go rest
in go l)
@@ -368,7 +368,7 @@ shsInit :: forall n sh. ShS (n : sh) -> ShS (Init (n : sh))
shsInit =
gcastWith (unsafeCoerceRefl
:: Init (Just n : MapJust sh) :~: MapJust (Init (n : sh))) $
- coerce (shxInit @_ @_ @Int)
+ coerce (shxInit @Int)
shsLast :: forall n sh. ShS (n : sh) -> SNat (Last (n : sh))
shsLast (ShS shx) =
@@ -381,31 +381,31 @@ shsAppend :: forall sh sh'. ShS sh -> ShS sh' -> ShS (sh ++ sh')
shsAppend =
gcastWith (unsafeCoerceRefl
:: MapJust sh ++ MapJust sh' :~: MapJust (sh ++ sh')) $
- coerce (shxAppend @_ @_ @Int)
+ coerce (shxAppend @_ @Int)
shsTakeLenPerm :: forall is sh. Perm is -> ShS sh -> ShS (TakeLen is sh)
shsTakeLenPerm =
gcastWith (unsafeCoerceRefl
:: TakeLen is (MapJust sh) :~: MapJust (TakeLen is sh)) $
- coerce shxTakeLenPerm
+ coerce (shxTakeLenPerm @Int)
shsDropLenPerm :: forall is sh. Perm is -> ShS sh -> ShS (DropLen is sh)
shsDropLenPerm =
gcastWith (unsafeCoerceRefl
:: DropLen is (MapJust sh) :~: MapJust (DropLen is sh)) $
- coerce shxDropLenPerm
+ coerce (shxDropLenPerm @Int)
shsPermute :: forall is sh. Perm is -> ShS sh -> ShS (Permute is sh)
shsPermute =
gcastWith (unsafeCoerceRefl
:: Permute is (MapJust sh) :~: MapJust (Permute is sh)) $
- coerce shxPermute
+ coerce (shxPermute @Int)
shsIndex :: forall i sh. SNat i -> ShS sh -> SNat (Index i sh)
shsIndex i (ShS sh) =
gcastWith (unsafeCoerceRefl
:: Index i (MapJust sh) :~: Just (Index i sh)) $
- case shxIndex @_ @_ @Int i sh of
+ case shxIndex @Int i sh of
SKnown SNat -> SNat
shsPermutePrefix :: forall is sh. Perm is -> ShS sh -> ShS (PermutePrefix is sh)