Hi Jake
https://hackage.haskell.org/package/applicative-numbers can generate those instances.
Regards
Adam
Is it possible to automatically derive instances of Numeric type classes like Num, Fractional, Real, Floating, etc?I currently have two datatypes, Pair and Triple, that are defined like this:data Pair a = Pair a adata Triple a = Triple a a aI wrote these pretty trivial instances for Num and Floating:instance Num a => Num (Pair a) where(+) = liftA2 (+)(*) = liftA2 (*)abs = liftA absnegate = liftA negatesignum = liftA signumfromInteger = pure . fromIntegerinstance Fractional a => Fractional (Pair a) where(/) = liftA2 (/)recip = liftA recipfromRational = pure . fromRationaland practically identical instances for Triple as well.Is there anyway to have GHC derive these instances and the other numeric type classes?Thanks,Jake
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe