From 8db33035826609bf48e15a82742981a58a0b5982 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 26 Apr 2025 10:27:39 +0200 Subject: Refactor the clever replicate-aware Show instances --- src/Data/Array/Mixed/XArray.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/Data/Array/Mixed/XArray.hs') diff --git a/src/Data/Array/Mixed/XArray.hs b/src/Data/Array/Mixed/XArray.hs index 91a11ed..93484dc 100644 --- a/src/Data/Array/Mixed/XArray.hs +++ b/src/Data/Array/Mixed/XArray.hs @@ -15,6 +15,9 @@ module Data.Array.Mixed.XArray where import Control.DeepSeq (NFData) +import Data.Array.Internal.RankedG qualified as ORG +import Data.Array.Internal.RankedS qualified as ORS +import Data.Array.Internal qualified as OI import Data.Array.Ranked qualified as ORB import Data.Array.RankedS qualified as S import Data.Coerce @@ -59,6 +62,12 @@ fromVector sh v toVector :: Storable a => XArray sh a -> VS.Vector a toVector (XArray arr) = S.toVector arr +-- | This allows observing the strides in the underlying orthotope array. This +-- can be useful for optimisation, but should be considered an implementation +-- detail: strides may change in new versions of this library without notice. +arrayStrides :: XArray sh a -> [Int] +arrayStrides (XArray (ORS.A (ORG.A _ (OI.T strides _ _)))) = strides + scalar :: Storable a => a -> XArray '[] a scalar = XArray . S.scalar -- cgit v1.2.3-70-g09d2