aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Mixed.hs
diff options
context:
space:
mode:
authorMikolaj Konarski <mikolaj.konarski@gmail.com>2024-04-21 18:49:54 +0200
committerMikolaj Konarski <mikolaj.konarski@gmail.com>2024-04-21 18:54:03 +0200
commit2c3d1e4884eee109ca72286244eef4b357d586b8 (patch)
tree194427a565ecffb5101f0de2f4a9037e3097f747 /src/Data/Array/Mixed.hs
parentb3c92786635568e652b98095c3d0db5b4ec312b2 (diff)
Flesh out shaped sized lists
Diffstat (limited to 'src/Data/Array/Mixed.hs')
-rw-r--r--src/Data/Array/Mixed.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs
index c19fbe5..d2765b6 100644
--- a/src/Data/Array/Mixed.hs
+++ b/src/Data/Array/Mixed.hs
@@ -44,6 +44,8 @@ lemAppNil = unsafeCoerce Refl
lemAppAssoc :: Proxy a -> Proxy b -> Proxy c -> (a ++ b) ++ c :~: a ++ (b ++ c)
lemAppAssoc _ _ _ = unsafeCoerce Refl
+-- TODO: ListX? But if so, why is StaticShapeX not defined as a newtype
+-- over IxX (so that we can make IxX and StaticShapeX a newtype over ListX)?
type IxX :: Type -> [Maybe Nat] -> Type
data IxX i sh where
@@ -317,7 +319,7 @@ rerank2 ssh ssh1 ssh2 f (XArray arr1) (XArray arr2)
unXArray (XArray a) = a
-- | The list argument gives indices into the original dimension list.
-transpose :: forall sh a. KnownShapeX sh => [Int] -> XArray sh a -> XArray sh a
+transpose :: forall sh a. KnownShapeX sh => [Int] -> XArray sh a -> XArray sh a
transpose perm (XArray arr)
| Dict <- lemKnownINatRankSSX (knownShapeX @sh)
, Dict <- knownNatFromINat (Proxy @(Rank sh))
@@ -360,7 +362,7 @@ fromList ssh l
= case ssh of
m@GHC_SNat :$@ _ | natVal m /= fromIntegral (length l) ->
error $ "Data.Array.Mixed.fromList: length of list (" ++ show (length l) ++ ")" ++
- "does not match the type (" ++ show (natVal m) ++ ")"
+ "does not match the type (" ++ show (natVal m) ++ ")"
_ -> XArray (S.ravel (ORB.fromList [length l] (coerce @[XArray sh a] @[S.Array (FromINat (Rank sh)) a] l)))
toList :: Storable a => XArray (n : sh) a -> [XArray sh a]