{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE KindSignatures #-}
module Data.JoinSemilattice.Class.Fractional where
import Data.Hashable (Hashable)
import Data.JoinSemilattice.Defined (Defined)
import Data.JoinSemilattice.Intersect (Intersect)
import Data.JoinSemilattice.Class.Sum (SumR)
import Data.Kind (Type)
class SumR x => FractionalR (x :: Type) where
multiplyR :: ( x, x, x ) -> ( x, x, x )
default multiplyR :: Fractional x => ( x, x, x ) -> ( x, x, x )
multiplyR ( x
x, x
y, x
z ) = ( x
z x -> x -> x
forall a. Fractional a => a -> a -> a
/ x
y, x
z x -> x -> x
forall a. Fractional a => a -> a -> a
/ x
x, x
x x -> x -> x
forall a. Num a => a -> a -> a
* x
y )
divideR :: FractionalR x => ( x, x, x ) -> ( x, x, x )
divideR :: (x, x, x) -> (x, x, x)
divideR ( x
x, x
y, x
z ) = let ( x
z', x
y', x
x' ) = (x, x, x) -> (x, x, x)
forall x. FractionalR x => (x, x, x) -> (x, x, x)
multiplyR ( x
z, x
y, x
x ) in ( x
x', x
y', x
z' )
recipR :: (FractionalR x, Num x) => ( x, x ) -> ( x, x )
recipR :: (x, x) -> (x, x)
recipR ( x
x, x
y ) = let ( x
x', x
y', x
_ ) = (x, x, x) -> (x, x, x)
forall x. FractionalR x => (x, x, x) -> (x, x, x)
multiplyR ( x
x, x
y, x
1 ) in ( x
x', x
y' )
instance (Eq x, Fractional x) => FractionalR (Defined x)
instance (Bounded x, Enum x, Ord x, Fractional x, Hashable x)
=> FractionalR (Intersect x)