module Data.Field
(
Field
, divide
, fromRational
, recip
, (/)
) where
import Prelude hiding (fromInteger, fromRational, negate, quot, recip, (/))
import Data.Euclidean (Field, quot)
import Data.Ratio (denominator, numerator)
import Data.Semiring (fromInteger, one)
divide :: Field a => a -> a -> a
divide :: a -> a -> a
divide = a -> a -> a
forall a. Euclidean a => a -> a -> a
quot
{-# INLINE divide #-}
infixl 7 `divide`
recip :: Field a => a -> a
recip :: a -> a
recip = a -> a -> a
forall a. Euclidean a => a -> a -> a
quot a
forall a. Semiring a => a
one
{-# INLINE recip #-}
(/) :: Field a => a -> a -> a
/ :: a -> a -> a
(/) = a -> a -> a
forall a. Euclidean a => a -> a -> a
quot
{-# INLINE (/) #-}
infixl 7 /
fromRational :: Field a => Rational -> a
fromRational :: Rational -> a
fromRational Rational
x = a -> a -> a
forall a. Euclidean a => a -> a -> a
quot (Integer -> a
forall a. Ring a => Integer -> a
fromInteger (Rational -> Integer
forall a. Ratio a -> a
numerator Rational
x)) (Integer -> a
forall a. Ring a => Integer -> a
fromInteger (Rational -> Integer
forall a. Ratio a -> a
denominator Rational
x))
{-# INLINE fromRational #-}