From c5b11c52ef3353fd64cad337edc67b6287db09fb Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Fri, 18 Oct 2024 13:02:12 +0200 Subject: Support arrays of Bool --- src/Data/Array/Nested/Internal/Mixed.hs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Data/Array') diff --git a/src/Data/Array/Nested/Internal/Mixed.hs b/src/Data/Array/Nested/Internal/Mixed.hs index 731dbef..a979bf1 100644 --- a/src/Data/Array/Nested/Internal/Mixed.hs +++ b/src/Data/Array/Nested/Internal/Mixed.hs @@ -112,6 +112,7 @@ class (Storable a, Elt a) => PrimElt a where toPrimitive = coerce -- [PRIMITIVE ELEMENT TYPES LIST] +instance PrimElt Bool instance PrimElt Int instance PrimElt Int64 instance PrimElt Int32 @@ -147,6 +148,7 @@ deriving instance (Ord a, Storable a) => Ord (Mixed sh (Primitive a)) instance NFData a => NFData (Mixed sh (Primitive a)) -- [PRIMITIVE ELEMENT TYPES LIST] +newtype instance Mixed sh Bool = M_Bool (Mixed sh (Primitive Bool)) deriving (Eq, Generic) deriving (Show) via (ShowViaPrimitive sh Bool) newtype instance Mixed sh Int = M_Int (Mixed sh (Primitive Int)) deriving (Eq, Generic) deriving (Show) via (ShowViaPrimitive sh Int) newtype instance Mixed sh Int64 = M_Int64 (Mixed sh (Primitive Int64)) deriving (Eq, Generic) deriving (Show) via (ShowViaPrimitive sh Int64) newtype instance Mixed sh Int32 = M_Int32 (Mixed sh (Primitive Int32)) deriving (Eq, Generic) deriving (Show) via (ShowViaPrimitive sh Int32) @@ -157,6 +159,7 @@ newtype instance Mixed sh () = M_Nil (Mixed sh (Primitive ())) deriving (Eq, Gen -- etc. -- [PRIMITIVE ELEMENT TYPES LIST] +deriving instance Ord (Mixed sh Bool) ; instance NFData (Mixed sh Bool) deriving instance Ord (Mixed sh Int) ; instance NFData (Mixed sh Int) deriving instance Ord (Mixed sh Int64) ; instance NFData (Mixed sh Int64) deriving instance Ord (Mixed sh Int32) ; instance NFData (Mixed sh Int32) @@ -183,6 +186,7 @@ data family MixedVecs s sh a newtype instance MixedVecs s sh (Primitive a) = MV_Primitive (VS.MVector s a) -- [PRIMITIVE ELEMENT TYPES LIST] +newtype instance MixedVecs s sh Bool = MV_Bool (VS.MVector s Bool) newtype instance MixedVecs s sh Int = MV_Int (VS.MVector s Int) newtype instance MixedVecs s sh Int64 = MV_Int64 (VS.MVector s Int64) newtype instance MixedVecs s sh Int32 = MV_Int32 (VS.MVector s Int32) @@ -448,6 +452,7 @@ instance Storable a => Elt (Primitive a) where mvecsFreeze sh (MV_Primitive v) = M_Primitive sh . X.fromVector sh <$> VS.freeze v -- [PRIMITIVE ELEMENT TYPES LIST] +deriving via Primitive Bool instance Elt Bool deriving via Primitive Int instance Elt Int deriving via Primitive Int64 instance Elt Int64 deriving via Primitive Int32 instance Elt Int32 @@ -462,6 +467,7 @@ instance Storable a => KnownElt (Primitive a) where mvecsNewEmpty _ = MV_Primitive <$> VSM.unsafeNew 0 -- [PRIMITIVE ELEMENT TYPES LIST] +deriving via Primitive Bool instance KnownElt Bool deriving via Primitive Int instance KnownElt Int deriving via Primitive Int64 instance KnownElt Int64 deriving via Primitive Int32 instance KnownElt Int32 -- cgit v1.2.3-70-g09d2