<div dir="ltr">Is it possible to automatically derive instances of Numeric type classes like Num, Fractional, Real, Floating, etc?<div><br></div><div>I currently have two datatypes, Pair and Triple, that are defined like this:</div><div><br></div><div>data Pair a = Pair a a</div><div>data Triple a = Triple a a a</div><div><br></div><div>I wrote these pretty trivial instances for Num and Floating:</div><div><br></div><div><div>instance Num a => Num (Pair a) where</div><div>  (+) = liftA2 (+)</div><div>  (*) = liftA2 (*)</div><div>  abs = liftA abs</div><div>  negate = liftA negate</div><div>  signum = liftA signum</div><div>  fromInteger = pure . fromInteger</div><div><br></div><div>instance Fractional a => Fractional (Pair a) where</div><div>  (/) = liftA2 (/)</div><div>  recip = liftA recip</div><div>  fromRational = pure . fromRational</div></div><div><br></div><div>and practically identical instances for Triple as well.</div><div><br></div><div>Is there anyway to have GHC derive these instances and the other numeric type classes?</div><div><br></div><div>Thanks,</div><div>Jake</div></div>