module Incipit.Fractional where
import Data.Eq (Eq)
import Data.Maybe (Maybe (Just, Nothing))
import qualified GHC.Real as Real
import GHC.Real (Fractional)
import Incipit.Integral (safeOp)
(/) ::
Eq a =>
Fractional a =>
a ->
a ->
Maybe a
/ :: forall a. (Eq a, Fractional a) => a -> a -> Maybe a
(/) =
forall a b. (Eq a, Num a) => (a -> a -> b) -> a -> a -> Maybe b
safeOp forall a. Fractional a => a -> a -> a
(Real./)
recip ::
Eq a =>
Fractional a =>
a ->
Maybe a
recip :: forall a. (Eq a, Fractional a) => a -> Maybe a
recip = \case
a
0 ->
forall a. Maybe a
Nothing
a
a ->
forall a. a -> Maybe a
Just (forall a. Fractional a => a -> a
Real.recip a
a)