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/Shaped.hs | |
parent | cebce678a2b86b03796ef71ceec42664d180b107 (diff) |
Very unsafe fromInteger that crashes everything if you do it wrong
Diffstat (limited to 'src/Data/Array/Nested/Internal/Shaped.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal/Shaped.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Data/Array/Nested/Internal/Shaped.hs b/src/Data/Array/Nested/Internal/Shaped.hs index 9320495..863e604 100644 --- a/src/Data/Array/Nested/Internal/Shaped.hs +++ b/src/Data/Array/Nested/Internal/Shaped.hs @@ -179,21 +179,21 @@ arithPromoteShaped2 :: forall sh a. PrimElt a -> Shaped sh a -> Shaped sh a -> Shaped sh a arithPromoteShaped2 = coerce -instance (NumElt a, PrimElt a) => Num (Shaped sh a) where +instance (NumElt a, PrimElt a, Num a) => Num (Shaped sh a) where (+) = arithPromoteShaped2 (+) (-) = arithPromoteShaped2 (-) (*) = arithPromoteShaped2 (*) negate = arithPromoteShaped negate abs = arithPromoteShaped abs signum = arithPromoteShaped signum - fromInteger _ = error "Data.Array.Nested.fromIntegral: No singletons available, use explicit sreplicateScal" + fromInteger = Shaped . fromInteger -instance (FloatElt a, NumElt a, PrimElt a) => Fractional (Shaped sh a) where +instance (FloatElt a, NumElt a, PrimElt a, Num a) => Fractional (Shaped sh a) where fromRational _ = error "Data.Array.Nested.fromRational: No singletons available, use explicit sreplicateScal" recip = arithPromoteShaped recip (/) = arithPromoteShaped2 (/) -instance (FloatElt a, NumElt a, PrimElt a) => Floating (Shaped sh a) where +instance (FloatElt a, NumElt a, PrimElt a, Num a) => Floating (Shaped sh a) where pi = error "Data.Array.Nested.pi: No singletons available, use explicit sreplicateScal" exp = arithPromoteShaped exp log = arithPromoteShaped log |