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/Ranked.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/Ranked.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal/Ranked.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Data/Array/Nested/Internal/Ranked.hs b/src/Data/Array/Nested/Internal/Ranked.hs index 54094cc..b3d4f91 100644 --- a/src/Data/Array/Nested/Internal/Ranked.hs +++ b/src/Data/Array/Nested/Internal/Ranked.hs @@ -21,7 +21,7 @@ module Data.Array.Nested.Internal.Ranked where import Prelude hiding (mappend, mconcat) -import Control.DeepSeq (NFData) +import Control.DeepSeq (NFData(..)) import Control.Monad.ST import Data.Array.RankedS qualified as S import Data.Bifunctor (first) @@ -61,13 +61,15 @@ type Ranked :: Nat -> Type -> Type newtype Ranked n a = Ranked (Mixed (Replicate n Nothing) a) deriving instance Eq (Mixed (Replicate n Nothing) a) => Eq (Ranked n a) deriving instance Ord (Mixed (Replicate n Nothing) a) => Ord (Ranked n a) -deriving instance NFData (Mixed (Replicate n Nothing) a) => NFData (Ranked n a) instance (Show a, Elt a) => Show (Ranked n a) where showsPrec d arr = showParen (d > 10) $ showString "rfromListLinear " . shows (toList (rshape arr)) . showString " " . shows (rtoListLinear arr) +instance Elt a => NFData (Ranked n a) where + rnf (Ranked arr) = rnf arr + -- just unwrap the newtype and defer to the general instance for nested arrays newtype instance Mixed sh (Ranked n a) = M_Ranked (Mixed sh (Mixed (Replicate n Nothing) a)) @@ -125,6 +127,8 @@ instance Elt a => Elt (Ranked n a) where mconcat l = M_Ranked (mconcat (coerce l)) + mrnf (M_Ranked arr) = mrnf arr + type ShapeTree (Ranked n a) = (IShR n, ShapeTree a) mshapeTree (Ranked arr) = first shCvtXR' (mshapeTree arr) |