From fcb604ce7c3bb144292bf9a3d17b966d6790af05 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Fri, 14 Jun 2024 11:31:03 +0200 Subject: [mrs]{from,to}ListLinear --- src/Data/Array/Nested/Internal/Mixed.hs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Data/Array/Nested/Internal/Mixed.hs') diff --git a/src/Data/Array/Nested/Internal/Mixed.hs b/src/Data/Array/Nested/Internal/Mixed.hs index 8421372..d548794 100644 --- a/src/Data/Array/Nested/Internal/Mixed.hs +++ b/src/Data/Array/Nested/Internal/Mixed.hs @@ -742,6 +742,14 @@ mfromListPrimLinear sh l = let M_Primitive _ xarr = toPrimitive (mfromListPrim l) in fromPrimitive $ M_Primitive sh (X.reshape (SUnknown () :!% ZKX) sh xarr) +-- This forall is there so that a simple type application can constrain the +-- shape, in case the user wants to use OverloadedLists for the shape. +mfromListLinear :: forall sh a. Elt a => IShX sh -> NonEmpty a -> Mixed sh a +mfromListLinear sh l = mreshape sh (mfromList1 l) + +mtoListLinear :: Elt a => Mixed sh a -> [a] +mtoListLinear arr = map (mindex arr) (shxEnum (mshape arr)) -- TODO: optimise + munScalar :: Elt a => Mixed '[] a -> a munScalar arr = mindex arr ZIX -- cgit v1.2.3-70-g09d2