aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2026-03-14 11:52:03 +0100
committerTom Smeding <tom@tomsmeding.com>2026-03-14 12:01:53 +0100
commit8c27d35a43a18c7c169ea67ba131b94f10c4b25b (patch)
tree3c8e54ef1157108a7190df9b12c8d69450f229e8
parent832d9fb15b1d738c81f347b892d2af3b7663cafb (diff)
Variable naming and doc comments
-rw-r--r--src/Data/Array/Nested/Mixed.hs4
-rw-r--r--src/Data/Array/XArray.hs9
2 files changed, 5 insertions, 8 deletions
diff --git a/src/Data/Array/Nested/Mixed.hs b/src/Data/Array/Nested/Mixed.hs
index 16d5ffa..fe47cac 100644
--- a/src/Data/Array/Nested/Mixed.hs
+++ b/src/Data/Array/Nested/Mixed.hs
@@ -916,9 +916,9 @@ mfromList1PrimN n l =
mfromList1PrimSN :: PrimElt a => SNat n -> [a] -> Mixed '[Just n] a
mfromList1PrimSN sn l =
- let ssh = SKnown sn :$% ZSX
+ let sh = SKnown sn :$% ZSX
xarr = X.fromList1SN sn l
- in fromPrimitive $ M_Primitive ssh xarr
+ in fromPrimitive $ M_Primitive sh xarr
mfromListPrimLinear :: forall sh a. PrimElt a => IShX sh -> [a] -> Mixed sh a
mfromListPrimLinear sh l =
diff --git a/src/Data/Array/XArray.hs b/src/Data/Array/XArray.hs
index f3a1053..4514043 100644
--- a/src/Data/Array/XArray.hs
+++ b/src/Data/Array/XArray.hs
@@ -351,18 +351,15 @@ toListOuter (XArray arr@(ORS.A (ORG.A shArr t))) =
[_] | Refl <- (unsafeCoerceRefl :: sh :~: '[]) -> coerce (map S.scalar $ S.toList arr)
n : sh -> coerce $ map (ORG.A sh . OI.indexT t) [0 .. n - 1]
--- | If @n@ is an 'SKnown' dimension, the list is streamed. If @n@ is unknown,
--- the list's spine must be fully materialised to compute its length before
--- constructing the array.
+-- | Performance note: the list's spine is fully materialised to compute its
+-- length before traversing it again to construct the array.
{-# INLINE fromList1 #-}
fromList1 :: Storable a => [a] -> XArray '[Nothing] a
fromList1 l =
let n = length l -- avoid S.fromList because it takes a length _and_ does another length check itself
in XArray (S.fromVector [n] (VS.fromListN n l))
--- | If @n@ is an 'SKnown' dimension, the list is streamed. If @n@ is unknown,
--- the list's spine must be fully materialised to compute its length before
--- constructing the array.
+-- | The list is streamed.
{-# INLINE fromList1SN #-}
fromList1SN :: Storable a => SNat n -> [a] -> XArray '[Just n] a
fromList1SN m l =