diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-10-18 13:02:12 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-10-18 13:02:12 +0200 |
commit | c5b11c52ef3353fd64cad337edc67b6287db09fb (patch) | |
tree | b0258180b00ed25ba554fac38b36c5681228ef49 /src/Data | |
parent | f1b28a3090d47c75dd63e05469059b8f871cc10c (diff) |
Support arrays of Bool
Diffstat (limited to 'src/Data')
-rw-r--r-- | src/Data/Array/Nested/Internal/Mixed.hs | 6 |
1 files changed, 6 insertions, 0 deletions
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 |