diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-06-03 22:49:26 +0200 |
---|---|---|
committer | Tom Smeding <t.j.smeding@uu.nl> | 2024-06-10 16:33:30 +0200 |
commit | 890f4afd45ea416134ddfaf8a9115602316e17dc (patch) | |
tree | 0c21a1523d42802a82e902c017a0ed995823bd8c /src/Data/Array/Nested/Internal/Ranked.hs | |
parent | cebce678a2b86b03796ef71ceec42664d180b107 (diff) |
Very unsafe fromInteger that crashes everything if you do it wrong
Diffstat (limited to 'src/Data/Array/Nested/Internal/Ranked.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal/Ranked.hs | 8 |
1 files changed, 4 insertions, 4 deletions
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 |