From 890f4afd45ea416134ddfaf8a9115602316e17dc Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 3 Jun 2024 22:49:26 +0200 Subject: Very unsafe fromInteger that crashes everything if you do it wrong --- src/Data/Array/Nested/Internal/Ranked.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/Data/Array/Nested/Internal/Ranked.hs') diff --git a/src/Data/Array/Nested/Internal/Ranked.hs b/src/Data/Array/Nested/Internal/Ranked.hs index c67e892..3e9f528 100644 --- a/src/Data/Array/Nested/Internal/Ranked.hs +++ b/src/Data/Array/Nested/Internal/Ranked.hs @@ -184,21 +184,21 @@ arithPromoteRanked2 :: forall n a. PrimElt a -> Ranked n a -> Ranked n a -> Ranked n a arithPromoteRanked2 = coerce -instance (NumElt a, PrimElt a) => Num (Ranked n a) where +instance (NumElt a, PrimElt a, Num a) => Num (Ranked n a) where (+) = arithPromoteRanked2 (+) (-) = arithPromoteRanked2 (-) (*) = arithPromoteRanked2 (*) negate = arithPromoteRanked negate abs = arithPromoteRanked abs signum = arithPromoteRanked signum - fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit rreplicateScal" + fromInteger = Ranked . fromInteger -instance (FloatElt a, NumElt a, PrimElt a) => Fractional (Ranked n a) where +instance (FloatElt a, NumElt a, PrimElt a, Num a) => Fractional (Ranked n a) where fromRational _ = error "Data.Array.Nested.fromRational: No singletons available, use explicit rreplicateScal" recip = arithPromoteRanked recip (/) = arithPromoteRanked2 (/) -instance (FloatElt a, NumElt a, PrimElt a) => Floating (Ranked n a) where +instance (FloatElt a, NumElt a, PrimElt a, Num a) => Floating (Ranked n a) where pi = error "Data.Array.Nested.pi: No singletons available, use explicit rreplicateScal" exp = arithPromoteRanked exp log = arithPromoteRanked log -- cgit v1.2.3-70-g09d2