diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-05-23 09:17:56 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-05-23 09:17:56 +0200 |
commit | a77f07da16d94b93340bc4fcc391da1e817735d9 (patch) | |
tree | 277d2559514e4b0367a2f39e057da5825f5c82ce /src/Data/Array/Nested | |
parent | a0010622885dcb55a916bf3514c0e9040f6871e9 (diff) |
Clean up commented-out code
Diffstat (limited to 'src/Data/Array/Nested')
-rw-r--r-- | src/Data/Array/Nested/Internal.hs | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs index 831a9b5..a96a268 100644 --- a/src/Data/Array/Nested/Internal.hs +++ b/src/Data/Array/Nested/Internal.hs @@ -1001,20 +1001,6 @@ mliftPrim2 :: PrimElt a mliftPrim2 f (toPrimitive -> M_Primitive sh (X.XArray arr1)) (toPrimitive -> M_Primitive _ (X.XArray arr2)) = fromPrimitive $ M_Primitive sh (X.XArray (S.zipWithA f arr1 arr2)) -{-} -instance (Num a, PrimElt a) => Num (Mixed sh a) where - (+) = mliftPrim2 (+) - (-) = mliftPrim2 (-) - (*) = mliftPrim2 (*) - negate = mliftPrim negate - abs = mliftPrim abs - signum = mliftPrim signum - fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit mreplicate" - -type NumConstr a = Num a ---} - -{--} mliftNumElt1 :: PrimElt a => (SNat (Rank sh) -> S.Array (Rank sh) a -> S.Array (Rank sh) a) -> Mixed sh a -> Mixed sh a mliftNumElt1 f (toPrimitive -> M_Primitive sh (XArray arr)) = fromPrimitive $ M_Primitive sh (XArray (f (srankSh sh) arr)) @@ -1025,9 +1011,6 @@ mliftNumElt2 f (toPrimitive -> M_Primitive sh1 (XArray arr1)) (toPrimitive -> M_ | sh1 == sh2 = fromPrimitive $ M_Primitive sh1 (XArray (f (srankSh sh1) arr1 arr2)) | otherwise = error $ "Data.Array.Nested: Shapes unequal in elementwise Num operation: " ++ show sh1 ++ " vs " ++ show sh2 --- TODO: Clean up this mess and remove NumConstr -type NumConstr a = NumElt a - instance (NumElt a, PrimElt a) => Num (Mixed sh a) where (+) = mliftNumElt2 numEltAdd (-) = mliftNumElt2 numEltSub @@ -1038,12 +1021,12 @@ instance (NumElt a, PrimElt a) => Num (Mixed sh a) where fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit mreplicate" --} -instance (Fractional a, PrimElt a, NumConstr a) => Fractional (Mixed sh a) where +instance (NumElt a, PrimElt a, Fractional a) => Fractional (Mixed sh a) where fromRational _ = error "Data.Array.Nested.fromRational: No singletons available, use explicit mreplicate" recip = mliftPrim recip (/) = mliftPrim2 (/) -instance (Floating a, PrimElt a, NumConstr a) => Floating (Mixed sh a) where +instance (NumElt a, PrimElt a, Floating a) => Floating (Mixed sh a) where pi = error "Data.Array.Nested.pi: No singletons available, use explicit mreplicate" exp = mliftPrim exp log = mliftPrim log @@ -1346,7 +1329,7 @@ arithPromoteRanked2 :: forall n a. PrimElt a -> Ranked n a -> Ranked n a -> Ranked n a arithPromoteRanked2 = coerce -instance (NumConstr a, PrimElt a) => Num (Ranked n a) where +instance (NumElt a, PrimElt a) => Num (Ranked n a) where (+) = arithPromoteRanked2 (+) (-) = arithPromoteRanked2 (-) (*) = arithPromoteRanked2 (*) @@ -1355,12 +1338,12 @@ instance (NumConstr a, PrimElt a) => Num (Ranked n a) where signum = arithPromoteRanked signum fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit rreplicate" -instance (Fractional a, PrimElt a, NumConstr a) => Fractional (Ranked n a) where +instance (NumElt a, PrimElt a, Fractional a) => Fractional (Ranked n a) where fromRational _ = error "Data.Array.Nested.fromRational: No singletons available, use explicit rreplicate" recip = arithPromoteRanked recip (/) = arithPromoteRanked2 (/) -instance (Floating a, PrimElt a, NumConstr a) => Floating (Ranked n a) where +instance (NumElt a, PrimElt a, Floating a) => Floating (Ranked n a) where pi = error "Data.Array.Nested.pi: No singletons available, use explicit rreplicate" exp = arithPromoteRanked exp log = arithPromoteRanked log @@ -1646,7 +1629,7 @@ arithPromoteShaped2 :: forall sh a. PrimElt a -> Shaped sh a -> Shaped sh a -> Shaped sh a arithPromoteShaped2 = coerce -instance (NumConstr a, PrimElt a) => Num (Shaped sh a) where +instance (NumElt a, PrimElt a) => Num (Shaped sh a) where (+) = arithPromoteShaped2 (+) (-) = arithPromoteShaped2 (-) (*) = arithPromoteShaped2 (*) @@ -1655,12 +1638,12 @@ instance (NumConstr a, PrimElt a) => Num (Shaped sh a) where signum = arithPromoteShaped signum fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit sreplicate" -instance (Fractional a, PrimElt a, NumConstr a) => Fractional (Shaped sh a) where +instance (NumElt a, PrimElt a, Fractional a) => Fractional (Shaped sh a) where fromRational _ = error "Data.Array.Nested.fromRational: No singletons available, use explicit sreplicate" recip = arithPromoteShaped recip (/) = arithPromoteShaped2 (/) -instance (Floating a, PrimElt a, NumConstr a) => Floating (Shaped sh a) where +instance (NumElt a, PrimElt a, Floating a) => Floating (Shaped sh a) where pi = error "Data.Array.Nested.pi: No singletons available, use explicit sreplicate" exp = arithPromoteShaped exp log = arithPromoteShaped log |