diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-12-18 22:12:06 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-12-18 22:12:26 +0100 |
commit | 637ca0e7dd7db16233731b40ccbc7f4cb5c63a40 (patch) | |
tree | 9b4aa6af2697383ee6cbdc80ab1a43281cfc4d82 /src/Data/Array/Nested/Internal/Shaped.hs | |
parent | 080f42a232b9e1124741d98427ce96b2c3ab1cf5 (diff) |
Uniformise NFData instance (by putting rnf in Elt)
This now depends on:
https://github.com/augustss/orthotope/pull/14
My sincere apologies.
Diffstat (limited to 'src/Data/Array/Nested/Internal/Shaped.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal/Shaped.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Data/Array/Nested/Internal/Shaped.hs b/src/Data/Array/Nested/Internal/Shaped.hs index efeb618..ece4272 100644 --- a/src/Data/Array/Nested/Internal/Shaped.hs +++ b/src/Data/Array/Nested/Internal/Shaped.hs @@ -20,7 +20,7 @@ module Data.Array.Nested.Internal.Shaped where import Prelude hiding (mappend, mconcat) -import Control.DeepSeq (NFData) +import Control.DeepSeq (NFData(..)) import Control.Monad.ST import Data.Array.Internal.ShapedS qualified as SS import Data.Array.Internal.ShapedG qualified as SG @@ -62,13 +62,15 @@ type Shaped :: [Nat] -> Type -> Type newtype Shaped sh a = Shaped (Mixed (MapJust sh) a) deriving instance Eq (Mixed (MapJust sh) a) => Eq (Shaped sh a) deriving instance Ord (Mixed (MapJust sh) a) => Ord (Shaped sh a) -deriving instance NFData (Mixed (MapJust sh) a) => NFData (Shaped sh a) instance (Show a, Elt a) => Show (Shaped sh a) where showsPrec d arr = showParen (d > 10) $ showString "sfromListLinear " . shows (shsToList (sshape arr)) . showString " " . shows (stoListLinear arr) +instance Elt a => NFData (Shaped sh a) where + rnf (Shaped arr) = rnf arr + -- just unwrap the newtype and defer to the general instance for nested arrays newtype instance Mixed sh (Shaped sh' a) = M_Shaped (Mixed sh (Mixed (MapJust sh') a)) @@ -123,6 +125,8 @@ instance Elt a => Elt (Shaped sh a) where mconcat l = M_Shaped (mconcat (coerce l)) + mrnf (M_Shaped arr) = mrnf arr + type ShapeTree (Shaped sh a) = (ShS sh, ShapeTree a) mshapeTree (Shaped arr) = first shCvtXS' (mshapeTree arr) |