From 2b0391b9a5885af1b551c83f2dc4b8ef2b48d7bf Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 20 Apr 2024 21:56:12 +0200 Subject: fromList1 (the analogue to orthotope's fromList) --- src/Data/Array/Nested/Internal.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Data/Array/Nested') diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs index f76b2ab..6f0cfc8 100644 --- a/src/Data/Array/Nested/Internal.hs +++ b/src/Data/Array/Nested/Internal.hs @@ -489,6 +489,9 @@ mfromVector sh v | otherwise = M_Primitive (X.fromVector sh v) +mfromList1 :: (KnownShapeX '[n], Elt a) => NonEmpty a -> Mixed '[n] a +mfromList1 = mfromList . fmap mscalar + munScalar :: Elt a => Mixed '[] a -> a munScalar arr = mindex arr IZX @@ -918,6 +921,9 @@ rfromVector sh v | Dict <- lemKnownReplicate (Proxy @n) = Ranked (mfromVector (ixCvtRX sh) v) +rfromList1 :: Elt a => NonEmpty a -> Ranked I1 a +rfromList1 = Ranked . mfromList . fmap mscalar + runScalar :: Elt a => Ranked I0 a -> a runScalar arr = rindex arr IZR @@ -1051,6 +1057,9 @@ sfromVector v | Dict <- lemKnownMapJust (Proxy @sh) = Shaped (mfromVector (ixCvtSX (cvtSShapeIxS (knownShape @sh))) v) +sfromList1 :: (KnownNat n, Elt a) => NonEmpty a -> Shaped '[n] a +sfromList1 = Shaped . mfromList . fmap mscalar + sunScalar :: Elt a => Shaped '[] a -> a sunScalar arr = sindex arr IZS -- cgit v1.2.3-70-g09d2