{-|
Module      : Linear.Geo.PlaneAngle
Copyright   : Travis Whitaker 2023
License     : MIT
Maintainer  : pi.boy.travis@gmail.com
Stability   : Provisional
Portability : Portable (Windows, POSIX)

Types for dealing with different representations of angles in the plane.

-}

{-# LANGUAGE BangPatterns
           , DeriveAnyClass
           , DeriveDataTypeable
           , DeriveFunctor
           , DeriveGeneric
           , DerivingStrategies
           , GeneralizedNewtypeDeriving
           #-}

module Linear.Geo.PlaneAngle (
    PlaneAngle(..)
  , Radians(..)
  , Degrees(..)
  , DMS(..)
  , dmsToDegrees
  , degreesToDMS
  , DM(..)
  , dmToDegrees
  , degreesToDM
  ) where

import Control.Applicative

import Control.DeepSeq (NFData)

import Control.Monad.Fix
import Control.Monad.Zip

import Data.Coerce

import Data.Data (Data)

import Data.Distributive

import Data.Fixed (divMod', mod')

import GHC.Generics (Generic)

-- | Plane angles.
class PlaneAngle ang where
    --  | Put the angle into the canonical range 0 to 2*pi.
    normalizeAngle :: (Floating a, Real a) => ang a -> ang a
    -- | Convert the angle to radians.
    toRadians      :: (Floating a, Real a) => ang a -> Radians a
    -- | Convert the angle from radians.
    fromRadians    :: (Floating a, Real a) => Radians a -> ang a

-- | A quantity representing a plane angle that satisfies the equation
--   @S = r * a@ where @r@ is the radius of a circle, @a@ is the measure of some
--   angle subtending the circle, and @S@ is the length of the subtended arc.
newtype Radians a = Radians a
                  deriving stock ( Radians a -> Radians a -> Bool
forall a. Eq a => Radians a -> Radians a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Radians a -> Radians a -> Bool
$c/= :: forall a. Eq a => Radians a -> Radians a -> Bool
== :: Radians a -> Radians a -> Bool
$c== :: forall a. Eq a => Radians a -> Radians a -> Bool
Eq
                                 , Radians a -> Radians a -> Bool
Radians a -> Radians a -> Ordering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (Radians a)
forall a. Ord a => Radians a -> Radians a -> Bool
forall a. Ord a => Radians a -> Radians a -> Ordering
forall a. Ord a => Radians a -> Radians a -> Radians a
min :: Radians a -> Radians a -> Radians a
$cmin :: forall a. Ord a => Radians a -> Radians a -> Radians a
max :: Radians a -> Radians a -> Radians a
$cmax :: forall a. Ord a => Radians a -> Radians a -> Radians a
>= :: Radians a -> Radians a -> Bool
$c>= :: forall a. Ord a => Radians a -> Radians a -> Bool
> :: Radians a -> Radians a -> Bool
$c> :: forall a. Ord a => Radians a -> Radians a -> Bool
<= :: Radians a -> Radians a -> Bool
$c<= :: forall a. Ord a => Radians a -> Radians a -> Bool
< :: Radians a -> Radians a -> Bool
$c< :: forall a. Ord a => Radians a -> Radians a -> Bool
compare :: Radians a -> Radians a -> Ordering
$ccompare :: forall a. Ord a => Radians a -> Radians a -> Ordering
Ord
                                 , Int -> Radians a -> ShowS
forall a. Show a => Int -> Radians a -> ShowS
forall a. Show a => [Radians a] -> ShowS
forall a. Show a => Radians a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Radians a] -> ShowS
$cshowList :: forall a. Show a => [Radians a] -> ShowS
show :: Radians a -> String
$cshow :: forall a. Show a => Radians a -> String
showsPrec :: Int -> Radians a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Radians a -> ShowS
Show
                                 , forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Radians a) x -> Radians a
forall a x. Radians a -> Rep (Radians a) x
$cto :: forall a x. Rep (Radians a) x -> Radians a
$cfrom :: forall a x. Radians a -> Rep (Radians a) x
Generic
                                 , Radians a -> DataType
Radians a -> Constr
forall {a}. Data a => Typeable (Radians a)
forall a. Data a => Radians a -> DataType
forall a. Data a => Radians a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Radians a -> Radians a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Radians a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Radians a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Radians a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Radians a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Radians a -> m (Radians a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Radians a -> m (Radians a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Radians a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Radians a -> c (Radians a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Radians a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Radians a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Radians a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Radians a -> c (Radians a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Radians a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Radians a -> m (Radians a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Radians a -> m (Radians a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Radians a -> m (Radians a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Radians a -> m (Radians a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Radians a -> m (Radians a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Radians a -> m (Radians a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Radians a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Radians a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Radians a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Radians a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Radians a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Radians a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Radians a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Radians a -> r
gmapT :: (forall b. Data b => b -> b) -> Radians a -> Radians a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Radians a -> Radians a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Radians a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Radians a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Radians a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Radians a))
dataTypeOf :: Radians a -> DataType
$cdataTypeOf :: forall a. Data a => Radians a -> DataType
toConstr :: Radians a -> Constr
$ctoConstr :: forall a. Data a => Radians a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Radians a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Radians a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Radians a -> c (Radians a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Radians a -> c (Radians a)
Data
                                 , Radians a
forall a. a -> a -> Bounded a
forall a. Bounded a => Radians a
maxBound :: Radians a
$cmaxBound :: forall a. Bounded a => Radians a
minBound :: Radians a
$cminBound :: forall a. Bounded a => Radians a
Bounded
                                 , forall a b. a -> Radians b -> Radians a
forall a b. (a -> b) -> Radians a -> Radians b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Radians b -> Radians a
$c<$ :: forall a b. a -> Radians b -> Radians a
fmap :: forall a b. (a -> b) -> Radians a -> Radians b
$cfmap :: forall a b. (a -> b) -> Radians a -> Radians b
Functor
                                 )
                  deriving newtype ( Integer -> Radians a
Radians a -> Radians a
Radians a -> Radians a -> Radians a
forall a. Num a => Integer -> Radians a
forall a. Num a => Radians a -> Radians a
forall a. Num a => Radians a -> Radians a -> Radians a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Radians a
$cfromInteger :: forall a. Num a => Integer -> Radians a
signum :: Radians a -> Radians a
$csignum :: forall a. Num a => Radians a -> Radians a
abs :: Radians a -> Radians a
$cabs :: forall a. Num a => Radians a -> Radians a
negate :: Radians a -> Radians a
$cnegate :: forall a. Num a => Radians a -> Radians a
* :: Radians a -> Radians a -> Radians a
$c* :: forall a. Num a => Radians a -> Radians a -> Radians a
- :: Radians a -> Radians a -> Radians a
$c- :: forall a. Num a => Radians a -> Radians a -> Radians a
+ :: Radians a -> Radians a -> Radians a
$c+ :: forall a. Num a => Radians a -> Radians a -> Radians a
Num
                                   , Rational -> Radians a
Radians a -> Radians a
Radians a -> Radians a -> Radians a
forall {a}. Fractional a => Num (Radians a)
forall a. Fractional a => Rational -> Radians a
forall a. Fractional a => Radians a -> Radians a
forall a. Fractional a => Radians a -> Radians a -> Radians a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
fromRational :: Rational -> Radians a
$cfromRational :: forall a. Fractional a => Rational -> Radians a
recip :: Radians a -> Radians a
$crecip :: forall a. Fractional a => Radians a -> Radians a
/ :: Radians a -> Radians a -> Radians a
$c/ :: forall a. Fractional a => Radians a -> Radians a -> Radians a
Fractional
                                   , Radians a
Radians a -> Radians a
Radians a -> Radians a -> Radians a
forall {a}. Floating a => Fractional (Radians a)
forall a. Floating a => Radians a
forall a. Floating a => Radians a -> Radians a
forall a. Floating a => Radians a -> Radians a -> Radians a
forall a.
Fractional a
-> a
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> Floating a
log1mexp :: Radians a -> Radians a
$clog1mexp :: forall a. Floating a => Radians a -> Radians a
log1pexp :: Radians a -> Radians a
$clog1pexp :: forall a. Floating a => Radians a -> Radians a
expm1 :: Radians a -> Radians a
$cexpm1 :: forall a. Floating a => Radians a -> Radians a
log1p :: Radians a -> Radians a
$clog1p :: forall a. Floating a => Radians a -> Radians a
atanh :: Radians a -> Radians a
$catanh :: forall a. Floating a => Radians a -> Radians a
acosh :: Radians a -> Radians a
$cacosh :: forall a. Floating a => Radians a -> Radians a
asinh :: Radians a -> Radians a
$casinh :: forall a. Floating a => Radians a -> Radians a
tanh :: Radians a -> Radians a
$ctanh :: forall a. Floating a => Radians a -> Radians a
cosh :: Radians a -> Radians a
$ccosh :: forall a. Floating a => Radians a -> Radians a
sinh :: Radians a -> Radians a
$csinh :: forall a. Floating a => Radians a -> Radians a
atan :: Radians a -> Radians a
$catan :: forall a. Floating a => Radians a -> Radians a
acos :: Radians a -> Radians a
$cacos :: forall a. Floating a => Radians a -> Radians a
asin :: Radians a -> Radians a
$casin :: forall a. Floating a => Radians a -> Radians a
tan :: Radians a -> Radians a
$ctan :: forall a. Floating a => Radians a -> Radians a
cos :: Radians a -> Radians a
$ccos :: forall a. Floating a => Radians a -> Radians a
sin :: Radians a -> Radians a
$csin :: forall a. Floating a => Radians a -> Radians a
logBase :: Radians a -> Radians a -> Radians a
$clogBase :: forall a. Floating a => Radians a -> Radians a -> Radians a
** :: Radians a -> Radians a -> Radians a
$c** :: forall a. Floating a => Radians a -> Radians a -> Radians a
sqrt :: Radians a -> Radians a
$csqrt :: forall a. Floating a => Radians a -> Radians a
log :: Radians a -> Radians a
$clog :: forall a. Floating a => Radians a -> Radians a
exp :: Radians a -> Radians a
$cexp :: forall a. Floating a => Radians a -> Radians a
pi :: Radians a
$cpi :: forall a. Floating a => Radians a
Floating
                                   , Radians a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Radians a)
forall {a}. Real a => Ord (Radians a)
forall a. Real a => Radians a -> Rational
toRational :: Radians a -> Rational
$ctoRational :: forall a. Real a => Radians a -> Rational
Real
                                   , forall b. Integral b => Radians a -> b
forall b. Integral b => Radians a -> (b, Radians a)
forall a.
Real a
-> Fractional a
-> (forall b. Integral b => a -> (b, a))
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> RealFrac a
forall {a}. RealFrac a => Fractional (Radians a)
forall {a}. RealFrac a => Real (Radians a)
forall a b. (RealFrac a, Integral b) => Radians a -> b
forall a b. (RealFrac a, Integral b) => Radians a -> (b, Radians a)
floor :: forall b. Integral b => Radians a -> b
$cfloor :: forall a b. (RealFrac a, Integral b) => Radians a -> b
ceiling :: forall b. Integral b => Radians a -> b
$cceiling :: forall a b. (RealFrac a, Integral b) => Radians a -> b
round :: forall b. Integral b => Radians a -> b
$cround :: forall a b. (RealFrac a, Integral b) => Radians a -> b
truncate :: forall b. Integral b => Radians a -> b
$ctruncate :: forall a b. (RealFrac a, Integral b) => Radians a -> b
properFraction :: forall b. Integral b => Radians a -> (b, Radians a)
$cproperFraction :: forall a b. (RealFrac a, Integral b) => Radians a -> (b, Radians a)
RealFrac
                                   , Int -> Radians a -> Radians a
Integer -> Int -> Radians a
Radians a -> Bool
Radians a -> Int
Radians a -> Integer
Radians a -> (Int, Int)
Radians a -> (Integer, Int)
Radians a -> Radians a
Radians a -> Radians a -> Radians a
forall {a}. RealFloat a => Floating (Radians a)
forall {a}. RealFloat a => RealFrac (Radians a)
forall a. RealFloat a => Int -> Radians a -> Radians a
forall a. RealFloat a => Integer -> Int -> Radians a
forall a. RealFloat a => Radians a -> Bool
forall a. RealFloat a => Radians a -> Int
forall a. RealFloat a => Radians a -> Integer
forall a. RealFloat a => Radians a -> (Int, Int)
forall a. RealFloat a => Radians a -> (Integer, Int)
forall a. RealFloat a => Radians a -> Radians a
forall a. RealFloat a => Radians a -> Radians a -> Radians a
forall a.
RealFrac a
-> Floating a
-> (a -> Integer)
-> (a -> Int)
-> (a -> (Int, Int))
-> (a -> (Integer, Int))
-> (Integer -> Int -> a)
-> (a -> Int)
-> (a -> a)
-> (Int -> a -> a)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> a -> a)
-> RealFloat a
atan2 :: Radians a -> Radians a -> Radians a
$catan2 :: forall a. RealFloat a => Radians a -> Radians a -> Radians a
isIEEE :: Radians a -> Bool
$cisIEEE :: forall a. RealFloat a => Radians a -> Bool
isNegativeZero :: Radians a -> Bool
$cisNegativeZero :: forall a. RealFloat a => Radians a -> Bool
isDenormalized :: Radians a -> Bool
$cisDenormalized :: forall a. RealFloat a => Radians a -> Bool
isInfinite :: Radians a -> Bool
$cisInfinite :: forall a. RealFloat a => Radians a -> Bool
isNaN :: Radians a -> Bool
$cisNaN :: forall a. RealFloat a => Radians a -> Bool
scaleFloat :: Int -> Radians a -> Radians a
$cscaleFloat :: forall a. RealFloat a => Int -> Radians a -> Radians a
significand :: Radians a -> Radians a
$csignificand :: forall a. RealFloat a => Radians a -> Radians a
exponent :: Radians a -> Int
$cexponent :: forall a. RealFloat a => Radians a -> Int
encodeFloat :: Integer -> Int -> Radians a
$cencodeFloat :: forall a. RealFloat a => Integer -> Int -> Radians a
decodeFloat :: Radians a -> (Integer, Int)
$cdecodeFloat :: forall a. RealFloat a => Radians a -> (Integer, Int)
floatRange :: Radians a -> (Int, Int)
$cfloatRange :: forall a. RealFloat a => Radians a -> (Int, Int)
floatDigits :: Radians a -> Int
$cfloatDigits :: forall a. RealFloat a => Radians a -> Int
floatRadix :: Radians a -> Integer
$cfloatRadix :: forall a. RealFloat a => Radians a -> Integer
RealFloat
                                   , Radians a -> ()
forall a. NFData a => Radians a -> ()
forall a. (a -> ()) -> NFData a
rnf :: Radians a -> ()
$crnf :: forall a. NFData a => Radians a -> ()
NFData
                                   )

instance Applicative Radians where
    pure :: forall a. a -> Radians a
pure = coerce :: forall a b. Coercible a b => a -> b
coerce
    Radians a -> b
f <*> :: forall a b. Radians (a -> b) -> Radians a -> Radians b
<*> Radians a
x = forall a. a -> Radians a
Radians (a -> b
f a
x)

instance Monad Radians where
    return :: forall a. a -> Radians a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
    Radians a
x >>= :: forall a b. Radians a -> (a -> Radians b) -> Radians b
>>= a -> Radians b
f = a -> Radians b
f a
x

instance MonadZip Radians where
    mzipWith :: forall a b c. (a -> b -> c) -> Radians a -> Radians b -> Radians c
mzipWith = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2

instance MonadFix Radians where
    mfix :: forall a. (a -> Radians a) -> Radians a
mfix a -> Radians a
f = forall a. a -> Radians a
Radians (let Radians a
x = a -> Radians a
f a
x in a
x)

instance Foldable Radians where
    foldMap :: forall m a. Monoid m => (a -> m) -> Radians a -> m
foldMap a -> m
f (Radians a
x) = a -> m
f a
x

instance Traversable Radians where
    traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Radians a -> f (Radians b)
traverse a -> f b
f (Radians a
x) = forall a. a -> Radians a
Radians forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
x

instance Distributive Radians where
    distribute :: forall (f :: * -> *) a. Functor f => f (Radians a) -> Radians (f a)
distribute f (Radians a)
f = forall a. a -> Radians a
Radians (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap coerce :: forall a b. Coercible a b => a -> b
coerce f (Radians a)
f)

instance PlaneAngle Radians where
    normalizeAngle :: forall a. (Floating a, Real a) => Radians a -> Radians a
normalizeAngle = coerce :: forall a b. Coercible a b => a -> b
coerce forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Real a => a -> a -> a
`mod'` (Radians a
2 forall a. Num a => a -> a -> a
* forall a. Floating a => a
pi))
    toRadians :: forall a. (Floating a, Real a) => Radians a -> Radians a
toRadians = forall a. a -> a
id
    fromRadians :: forall a. (Floating a, Real a) => Radians a -> Radians a
fromRadians = forall a. a -> a
id
    {-# INLINEABLE normalizeAngle #-}
    {-# INLINEABLE toRadians #-}
    {-# INLINEABLE fromRadians #-}

-- | One degree is @pi / 180@ radians.
newtype Degrees a = Degrees a
                  deriving stock ( Degrees a -> Degrees a -> Bool
forall a. Eq a => Degrees a -> Degrees a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Degrees a -> Degrees a -> Bool
$c/= :: forall a. Eq a => Degrees a -> Degrees a -> Bool
== :: Degrees a -> Degrees a -> Bool
$c== :: forall a. Eq a => Degrees a -> Degrees a -> Bool
Eq
                                 , Degrees a -> Degrees a -> Bool
Degrees a -> Degrees a -> Ordering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (Degrees a)
forall a. Ord a => Degrees a -> Degrees a -> Bool
forall a. Ord a => Degrees a -> Degrees a -> Ordering
forall a. Ord a => Degrees a -> Degrees a -> Degrees a
min :: Degrees a -> Degrees a -> Degrees a
$cmin :: forall a. Ord a => Degrees a -> Degrees a -> Degrees a
max :: Degrees a -> Degrees a -> Degrees a
$cmax :: forall a. Ord a => Degrees a -> Degrees a -> Degrees a
>= :: Degrees a -> Degrees a -> Bool
$c>= :: forall a. Ord a => Degrees a -> Degrees a -> Bool
> :: Degrees a -> Degrees a -> Bool
$c> :: forall a. Ord a => Degrees a -> Degrees a -> Bool
<= :: Degrees a -> Degrees a -> Bool
$c<= :: forall a. Ord a => Degrees a -> Degrees a -> Bool
< :: Degrees a -> Degrees a -> Bool
$c< :: forall a. Ord a => Degrees a -> Degrees a -> Bool
compare :: Degrees a -> Degrees a -> Ordering
$ccompare :: forall a. Ord a => Degrees a -> Degrees a -> Ordering
Ord
                                 , Int -> Degrees a -> ShowS
forall a. Show a => Int -> Degrees a -> ShowS
forall a. Show a => [Degrees a] -> ShowS
forall a. Show a => Degrees a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Degrees a] -> ShowS
$cshowList :: forall a. Show a => [Degrees a] -> ShowS
show :: Degrees a -> String
$cshow :: forall a. Show a => Degrees a -> String
showsPrec :: Int -> Degrees a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Degrees a -> ShowS
Show
                                 , forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Degrees a) x -> Degrees a
forall a x. Degrees a -> Rep (Degrees a) x
$cto :: forall a x. Rep (Degrees a) x -> Degrees a
$cfrom :: forall a x. Degrees a -> Rep (Degrees a) x
Generic
                                 , Degrees a -> DataType
Degrees a -> Constr
forall {a}. Data a => Typeable (Degrees a)
forall a. Data a => Degrees a -> DataType
forall a. Data a => Degrees a -> Constr
forall a.
Data a =>
(forall b. Data b => b -> b) -> Degrees a -> Degrees a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Degrees a -> u
forall a u.
Data a =>
(forall d. Data d => d -> u) -> Degrees a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Degrees a -> r
forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Degrees a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Degrees a -> m (Degrees a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Degrees a -> m (Degrees a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Degrees a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Degrees a -> c (Degrees a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Degrees a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Degrees a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Degrees a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Degrees a -> c (Degrees a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Degrees a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Degrees a -> m (Degrees a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Degrees a -> m (Degrees a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Degrees a -> m (Degrees a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> Degrees a -> m (Degrees a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Degrees a -> m (Degrees a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> Degrees a -> m (Degrees a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Degrees a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> Degrees a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Degrees a -> [u]
$cgmapQ :: forall a u.
Data a =>
(forall d. Data d => d -> u) -> Degrees a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Degrees a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> Degrees a -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Degrees a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> Degrees a -> r
gmapT :: (forall b. Data b => b -> b) -> Degrees a -> Degrees a
$cgmapT :: forall a.
Data a =>
(forall b. Data b => b -> b) -> Degrees a -> Degrees a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Degrees a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c (Degrees a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (Degrees a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (Degrees a))
dataTypeOf :: Degrees a -> DataType
$cdataTypeOf :: forall a. Data a => Degrees a -> DataType
toConstr :: Degrees a -> Constr
$ctoConstr :: forall a. Data a => Degrees a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Degrees a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (Degrees a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Degrees a -> c (Degrees a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Degrees a -> c (Degrees a)
Data
                                 , Degrees a
forall a. a -> a -> Bounded a
forall a. Bounded a => Degrees a
maxBound :: Degrees a
$cmaxBound :: forall a. Bounded a => Degrees a
minBound :: Degrees a
$cminBound :: forall a. Bounded a => Degrees a
Bounded
                                 , forall a b. a -> Degrees b -> Degrees a
forall a b. (a -> b) -> Degrees a -> Degrees b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> Degrees b -> Degrees a
$c<$ :: forall a b. a -> Degrees b -> Degrees a
fmap :: forall a b. (a -> b) -> Degrees a -> Degrees b
$cfmap :: forall a b. (a -> b) -> Degrees a -> Degrees b
Functor
                                 )
                  deriving newtype ( Integer -> Degrees a
Degrees a -> Degrees a
Degrees a -> Degrees a -> Degrees a
forall a. Num a => Integer -> Degrees a
forall a. Num a => Degrees a -> Degrees a
forall a. Num a => Degrees a -> Degrees a -> Degrees a
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> Degrees a
$cfromInteger :: forall a. Num a => Integer -> Degrees a
signum :: Degrees a -> Degrees a
$csignum :: forall a. Num a => Degrees a -> Degrees a
abs :: Degrees a -> Degrees a
$cabs :: forall a. Num a => Degrees a -> Degrees a
negate :: Degrees a -> Degrees a
$cnegate :: forall a. Num a => Degrees a -> Degrees a
* :: Degrees a -> Degrees a -> Degrees a
$c* :: forall a. Num a => Degrees a -> Degrees a -> Degrees a
- :: Degrees a -> Degrees a -> Degrees a
$c- :: forall a. Num a => Degrees a -> Degrees a -> Degrees a
+ :: Degrees a -> Degrees a -> Degrees a
$c+ :: forall a. Num a => Degrees a -> Degrees a -> Degrees a
Num
                                   , Rational -> Degrees a
Degrees a -> Degrees a
Degrees a -> Degrees a -> Degrees a
forall {a}. Fractional a => Num (Degrees a)
forall a. Fractional a => Rational -> Degrees a
forall a. Fractional a => Degrees a -> Degrees a
forall a. Fractional a => Degrees a -> Degrees a -> Degrees a
forall a.
Num a
-> (a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
fromRational :: Rational -> Degrees a
$cfromRational :: forall a. Fractional a => Rational -> Degrees a
recip :: Degrees a -> Degrees a
$crecip :: forall a. Fractional a => Degrees a -> Degrees a
/ :: Degrees a -> Degrees a -> Degrees a
$c/ :: forall a. Fractional a => Degrees a -> Degrees a -> Degrees a
Fractional
                                   , Degrees a
Degrees a -> Degrees a
Degrees a -> Degrees a -> Degrees a
forall {a}. Floating a => Fractional (Degrees a)
forall a. Floating a => Degrees a
forall a. Floating a => Degrees a -> Degrees a
forall a. Floating a => Degrees a -> Degrees a -> Degrees a
forall a.
Fractional a
-> a
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> Floating a
log1mexp :: Degrees a -> Degrees a
$clog1mexp :: forall a. Floating a => Degrees a -> Degrees a
log1pexp :: Degrees a -> Degrees a
$clog1pexp :: forall a. Floating a => Degrees a -> Degrees a
expm1 :: Degrees a -> Degrees a
$cexpm1 :: forall a. Floating a => Degrees a -> Degrees a
log1p :: Degrees a -> Degrees a
$clog1p :: forall a. Floating a => Degrees a -> Degrees a
atanh :: Degrees a -> Degrees a
$catanh :: forall a. Floating a => Degrees a -> Degrees a
acosh :: Degrees a -> Degrees a
$cacosh :: forall a. Floating a => Degrees a -> Degrees a
asinh :: Degrees a -> Degrees a
$casinh :: forall a. Floating a => Degrees a -> Degrees a
tanh :: Degrees a -> Degrees a
$ctanh :: forall a. Floating a => Degrees a -> Degrees a
cosh :: Degrees a -> Degrees a
$ccosh :: forall a. Floating a => Degrees a -> Degrees a
sinh :: Degrees a -> Degrees a
$csinh :: forall a. Floating a => Degrees a -> Degrees a
atan :: Degrees a -> Degrees a
$catan :: forall a. Floating a => Degrees a -> Degrees a
acos :: Degrees a -> Degrees a
$cacos :: forall a. Floating a => Degrees a -> Degrees a
asin :: Degrees a -> Degrees a
$casin :: forall a. Floating a => Degrees a -> Degrees a
tan :: Degrees a -> Degrees a
$ctan :: forall a. Floating a => Degrees a -> Degrees a
cos :: Degrees a -> Degrees a
$ccos :: forall a. Floating a => Degrees a -> Degrees a
sin :: Degrees a -> Degrees a
$csin :: forall a. Floating a => Degrees a -> Degrees a
logBase :: Degrees a -> Degrees a -> Degrees a
$clogBase :: forall a. Floating a => Degrees a -> Degrees a -> Degrees a
** :: Degrees a -> Degrees a -> Degrees a
$c** :: forall a. Floating a => Degrees a -> Degrees a -> Degrees a
sqrt :: Degrees a -> Degrees a
$csqrt :: forall a. Floating a => Degrees a -> Degrees a
log :: Degrees a -> Degrees a
$clog :: forall a. Floating a => Degrees a -> Degrees a
exp :: Degrees a -> Degrees a
$cexp :: forall a. Floating a => Degrees a -> Degrees a
pi :: Degrees a
$cpi :: forall a. Floating a => Degrees a
Floating
                                   , Degrees a -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
forall {a}. Real a => Num (Degrees a)
forall {a}. Real a => Ord (Degrees a)
forall a. Real a => Degrees a -> Rational
toRational :: Degrees a -> Rational
$ctoRational :: forall a. Real a => Degrees a -> Rational
Real
                                   , forall b. Integral b => Degrees a -> b
forall b. Integral b => Degrees a -> (b, Degrees a)
forall a.
Real a
-> Fractional a
-> (forall b. Integral b => a -> (b, a))
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> (forall b. Integral b => a -> b)
-> RealFrac a
forall {a}. RealFrac a => Fractional (Degrees a)
forall {a}. RealFrac a => Real (Degrees a)
forall a b. (RealFrac a, Integral b) => Degrees a -> b
forall a b. (RealFrac a, Integral b) => Degrees a -> (b, Degrees a)
floor :: forall b. Integral b => Degrees a -> b
$cfloor :: forall a b. (RealFrac a, Integral b) => Degrees a -> b
ceiling :: forall b. Integral b => Degrees a -> b
$cceiling :: forall a b. (RealFrac a, Integral b) => Degrees a -> b
round :: forall b. Integral b => Degrees a -> b
$cround :: forall a b. (RealFrac a, Integral b) => Degrees a -> b
truncate :: forall b. Integral b => Degrees a -> b
$ctruncate :: forall a b. (RealFrac a, Integral b) => Degrees a -> b
properFraction :: forall b. Integral b => Degrees a -> (b, Degrees a)
$cproperFraction :: forall a b. (RealFrac a, Integral b) => Degrees a -> (b, Degrees a)
RealFrac
                                   , Int -> Degrees a -> Degrees a
Integer -> Int -> Degrees a
Degrees a -> Bool
Degrees a -> Int
Degrees a -> Integer
Degrees a -> (Int, Int)
Degrees a -> (Integer, Int)
Degrees a -> Degrees a
Degrees a -> Degrees a -> Degrees a
forall {a}. RealFloat a => Floating (Degrees a)
forall {a}. RealFloat a => RealFrac (Degrees a)
forall a. RealFloat a => Int -> Degrees a -> Degrees a
forall a. RealFloat a => Integer -> Int -> Degrees a
forall a. RealFloat a => Degrees a -> Bool
forall a. RealFloat a => Degrees a -> Int
forall a. RealFloat a => Degrees a -> Integer
forall a. RealFloat a => Degrees a -> (Int, Int)
forall a. RealFloat a => Degrees a -> (Integer, Int)
forall a. RealFloat a => Degrees a -> Degrees a
forall a. RealFloat a => Degrees a -> Degrees a -> Degrees a
forall a.
RealFrac a
-> Floating a
-> (a -> Integer)
-> (a -> Int)
-> (a -> (Int, Int))
-> (a -> (Integer, Int))
-> (Integer -> Int -> a)
-> (a -> Int)
-> (a -> a)
-> (Int -> a -> a)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> Bool)
-> (a -> a -> a)
-> RealFloat a
atan2 :: Degrees a -> Degrees a -> Degrees a
$catan2 :: forall a. RealFloat a => Degrees a -> Degrees a -> Degrees a
isIEEE :: Degrees a -> Bool
$cisIEEE :: forall a. RealFloat a => Degrees a -> Bool
isNegativeZero :: Degrees a -> Bool
$cisNegativeZero :: forall a. RealFloat a => Degrees a -> Bool
isDenormalized :: Degrees a -> Bool
$cisDenormalized :: forall a. RealFloat a => Degrees a -> Bool
isInfinite :: Degrees a -> Bool
$cisInfinite :: forall a. RealFloat a => Degrees a -> Bool
isNaN :: Degrees a -> Bool
$cisNaN :: forall a. RealFloat a => Degrees a -> Bool
scaleFloat :: Int -> Degrees a -> Degrees a
$cscaleFloat :: forall a. RealFloat a => Int -> Degrees a -> Degrees a
significand :: Degrees a -> Degrees a
$csignificand :: forall a. RealFloat a => Degrees a -> Degrees a
exponent :: Degrees a -> Int
$cexponent :: forall a. RealFloat a => Degrees a -> Int
encodeFloat :: Integer -> Int -> Degrees a
$cencodeFloat :: forall a. RealFloat a => Integer -> Int -> Degrees a
decodeFloat :: Degrees a -> (Integer, Int)
$cdecodeFloat :: forall a. RealFloat a => Degrees a -> (Integer, Int)
floatRange :: Degrees a -> (Int, Int)
$cfloatRange :: forall a. RealFloat a => Degrees a -> (Int, Int)
floatDigits :: Degrees a -> Int
$cfloatDigits :: forall a. RealFloat a => Degrees a -> Int
floatRadix :: Degrees a -> Integer
$cfloatRadix :: forall a. RealFloat a => Degrees a -> Integer
RealFloat
                                   , Degrees a -> ()
forall a. NFData a => Degrees a -> ()
forall a. (a -> ()) -> NFData a
rnf :: Degrees a -> ()
$crnf :: forall a. NFData a => Degrees a -> ()
NFData
                                   )

instance Applicative Degrees where
    pure :: forall a. a -> Degrees a
pure = coerce :: forall a b. Coercible a b => a -> b
coerce
    Degrees a -> b
f <*> :: forall a b. Degrees (a -> b) -> Degrees a -> Degrees b
<*> Degrees a
x = forall a. a -> Degrees a
Degrees (a -> b
f a
x)

instance Monad Degrees where
    return :: forall a. a -> Degrees a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
    Degrees a
x >>= :: forall a b. Degrees a -> (a -> Degrees b) -> Degrees b
>>= a -> Degrees b
f = a -> Degrees b
f a
x

instance MonadZip Degrees where
    mzipWith :: forall a b c. (a -> b -> c) -> Degrees a -> Degrees b -> Degrees c
mzipWith = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2

instance MonadFix Degrees where
    mfix :: forall a. (a -> Degrees a) -> Degrees a
mfix a -> Degrees a
f = forall a. a -> Degrees a
Degrees (let Degrees a
x = a -> Degrees a
f a
x in a
x)

instance Foldable Degrees where
    foldMap :: forall m a. Monoid m => (a -> m) -> Degrees a -> m
foldMap a -> m
f (Degrees a
x) = a -> m
f a
x

instance Traversable Degrees where
    traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Degrees a -> f (Degrees b)
traverse a -> f b
f (Degrees a
x) = forall a. a -> Degrees a
Degrees forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
x

instance Distributive Degrees where
    distribute :: forall (f :: * -> *) a. Functor f => f (Degrees a) -> Degrees (f a)
distribute f (Degrees a)
f = forall a. a -> Degrees a
Degrees (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap coerce :: forall a b. Coercible a b => a -> b
coerce f (Degrees a)
f)

instance PlaneAngle Degrees where
    normalizeAngle :: forall a. (Floating a, Real a) => Degrees a -> Degrees a
normalizeAngle = coerce :: forall a b. Coercible a b => a -> b
coerce forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. Real a => a -> a -> a
`mod'` Degrees a
360)
    toRadians :: forall a. (Floating a, Real a) => Degrees a -> Radians a
toRadians (Degrees a
d) = forall a. a -> Radians a
Radians (forall a. Floating a => a
pi forall a. Num a => a -> a -> a
* (a
d forall a. Fractional a => a -> a -> a
/ a
180))
    fromRadians :: forall a. (Floating a, Real a) => Radians a -> Degrees a
fromRadians (Radians a
r) = forall a. a -> Degrees a
Degrees ((a
r forall a. Fractional a => a -> a -> a
/ forall a. Floating a => a
pi) forall a. Num a => a -> a -> a
* a
180)
    {-# INLINEABLE normalizeAngle #-}
    {-# INLINEABLE toRadians #-}
    {-# INLINEABLE fromRadians #-}

-- | An angle represented as degrees, minutes, and seconds of arc.
data DMS a = DMS {
   forall a. DMS a -> a
dmsDeg :: !a
 , forall a. DMS a -> a
dmsMin :: !a
 , forall a. DMS a -> a
dmsSec :: !a
 } deriving stock ( DMS a -> DMS a -> Bool
forall a. Eq a => DMS a -> DMS a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DMS a -> DMS a -> Bool
$c/= :: forall a. Eq a => DMS a -> DMS a -> Bool
== :: DMS a -> DMS a -> Bool
$c== :: forall a. Eq a => DMS a -> DMS a -> Bool
Eq
                  , DMS a -> DMS a -> Bool
DMS a -> DMS a -> Ordering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (DMS a)
forall a. Ord a => DMS a -> DMS a -> Bool
forall a. Ord a => DMS a -> DMS a -> Ordering
forall a. Ord a => DMS a -> DMS a -> DMS a
min :: DMS a -> DMS a -> DMS a
$cmin :: forall a. Ord a => DMS a -> DMS a -> DMS a
max :: DMS a -> DMS a -> DMS a
$cmax :: forall a. Ord a => DMS a -> DMS a -> DMS a
>= :: DMS a -> DMS a -> Bool
$c>= :: forall a. Ord a => DMS a -> DMS a -> Bool
> :: DMS a -> DMS a -> Bool
$c> :: forall a. Ord a => DMS a -> DMS a -> Bool
<= :: DMS a -> DMS a -> Bool
$c<= :: forall a. Ord a => DMS a -> DMS a -> Bool
< :: DMS a -> DMS a -> Bool
$c< :: forall a. Ord a => DMS a -> DMS a -> Bool
compare :: DMS a -> DMS a -> Ordering
$ccompare :: forall a. Ord a => DMS a -> DMS a -> Ordering
Ord
                  , Int -> DMS a -> ShowS
forall a. Show a => Int -> DMS a -> ShowS
forall a. Show a => [DMS a] -> ShowS
forall a. Show a => DMS a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DMS a] -> ShowS
$cshowList :: forall a. Show a => [DMS a] -> ShowS
show :: DMS a -> String
$cshow :: forall a. Show a => DMS a -> String
showsPrec :: Int -> DMS a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> DMS a -> ShowS
Show
                  , forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (DMS a) x -> DMS a
forall a x. DMS a -> Rep (DMS a) x
$cto :: forall a x. Rep (DMS a) x -> DMS a
$cfrom :: forall a x. DMS a -> Rep (DMS a) x
Generic
                  , DMS a -> DataType
DMS a -> Constr
forall {a}. Data a => Typeable (DMS a)
forall a. Data a => DMS a -> DataType
forall a. Data a => DMS a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> DMS a -> DMS a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> DMS a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> DMS a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DMS a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DMS a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> DMS a -> m (DMS a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> DMS a -> m (DMS a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (DMS a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DMS a -> c (DMS a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (DMS a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (DMS a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (DMS a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DMS a -> c (DMS a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (DMS a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DMS a -> m (DMS a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> DMS a -> m (DMS a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DMS a -> m (DMS a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> DMS a -> m (DMS a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DMS a -> m (DMS a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> DMS a -> m (DMS a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DMS a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> DMS a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> DMS a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> DMS a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DMS a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DMS a -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DMS a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DMS a -> r
gmapT :: (forall b. Data b => b -> b) -> DMS a -> DMS a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> DMS a -> DMS a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (DMS a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (DMS a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (DMS a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (DMS a))
dataTypeOf :: DMS a -> DataType
$cdataTypeOf :: forall a. Data a => DMS a -> DataType
toConstr :: DMS a -> Constr
$ctoConstr :: forall a. Data a => DMS a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (DMS a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (DMS a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DMS a -> c (DMS a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DMS a -> c (DMS a)
Data
                  , DMS a
forall a. a -> a -> Bounded a
forall a. Bounded a => DMS a
maxBound :: DMS a
$cmaxBound :: forall a. Bounded a => DMS a
minBound :: DMS a
$cminBound :: forall a. Bounded a => DMS a
Bounded
                  , forall a b. a -> DMS b -> DMS a
forall a b. (a -> b) -> DMS a -> DMS b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> DMS b -> DMS a
$c<$ :: forall a b. a -> DMS b -> DMS a
fmap :: forall a b. (a -> b) -> DMS a -> DMS b
$cfmap :: forall a b. (a -> b) -> DMS a -> DMS b
Functor
                  )
   deriving anyclass (forall a. NFData a => DMS a -> ()
forall a. (a -> ()) -> NFData a
rnf :: DMS a -> ()
$crnf :: forall a. NFData a => DMS a -> ()
NFData)

instance Applicative DMS where
    pure :: forall a. a -> DMS a
pure a
x = forall a. a -> a -> a -> DMS a
DMS a
x a
x a
x
    (DMS a -> b
df a -> b
mf a -> b
sf) <*> :: forall a b. DMS (a -> b) -> DMS a -> DMS b
<*> (DMS a
d a
m a
s) = forall a. a -> a -> a -> DMS a
DMS (a -> b
df a
d) (a -> b
mf a
m) (a -> b
sf a
s)

instance Monad DMS where
    return :: forall a. a -> DMS a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
    (DMS a
d a
m a
s) >>= :: forall a b. DMS a -> (a -> DMS b) -> DMS b
>>= a -> DMS b
f = let DMS b
d' b
_ b
_ = a -> DMS b
f a
d
                            DMS b
_ b
m' b
_ = a -> DMS b
f a
m
                            DMS b
_ b
_ b
s' = a -> DMS b
f a
s
                        in forall a. a -> a -> a -> DMS a
DMS b
d' b
m' b
s'

instance MonadZip DMS where
    mzipWith :: forall a b c. (a -> b -> c) -> DMS a -> DMS b -> DMS c
mzipWith = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2

instance MonadFix DMS where
    mfix :: forall a. (a -> DMS a) -> DMS a
mfix a -> DMS a
f = forall a. a -> a -> a -> DMS a
DMS (let DMS a
d a
_ a
_ = a -> DMS a
f a
d in a
d)
                 (let DMS a
_ a
m a
_ = a -> DMS a
f a
m in a
m)
                 (let DMS a
_ a
_ a
s = a -> DMS a
f a
s in a
s)

instance Foldable DMS where
    foldMap :: forall m a. Monoid m => (a -> m) -> DMS a -> m
foldMap a -> m
f (DMS a
d a
m a
s) = a -> m
f a
d forall a. Semigroup a => a -> a -> a
<> a -> m
f a
m forall a. Semigroup a => a -> a -> a
<> a -> m
f a
s

instance Traversable DMS where
    traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> DMS a -> f (DMS b)
traverse a -> f b
f (DMS a
d a
m a
s) = forall a. a -> a -> a -> DMS a
DMS forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
d forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
m forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
s

instance Distributive DMS where
    distribute :: forall (f :: * -> *) a. Functor f => f (DMS a) -> DMS (f a)
distribute f (DMS a)
f = forall a. a -> a -> a -> DMS a
DMS (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(DMS a
d a
_ a
_) -> a
d) f (DMS a)
f)
                       (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(DMS a
_ a
m a
_) -> a
m) f (DMS a)
f)
                       (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(DMS a
_ a
_ a
s) -> a
s) f (DMS a)
f)

-- | Convert DMS to Degrees. This does not normalize the angle.
dmsToDegrees :: Fractional a => DMS a -> Degrees a
dmsToDegrees :: forall a. Fractional a => DMS a -> Degrees a
dmsToDegrees (DMS a
d a
m a
s) = forall a. a -> Degrees a
Degrees (a
d forall a. Num a => a -> a -> a
+ (a
m forall a. Num a => a -> a -> a
* (a
1 forall a. Fractional a => a -> a -> a
/ a
60)) forall a. Num a => a -> a -> a
+ (a
s forall a. Num a => a -> a -> a
* (a
1 forall a. Fractional a => a -> a -> a
/ a
3600)))
{-# INLINEABLE dmsToDegrees #-}

-- | Convert degrees to DMS. This does not normalize the angle.
degreesToDMS :: (Real a, Fractional a) => Degrees a -> DMS a
degreesToDMS :: forall a. (Real a, Fractional a) => Degrees a -> DMS a
degreesToDMS (Degrees a
d) =
    let (Integer
dint, a
dleft) = forall a b. (Real a, Integral b) => a -> a -> (b, a)
divMod' a
d a
1
        (Integer
mint, a
mleft) = forall a b. (Real a, Integral b) => a -> a -> (b, a)
divMod' a
dleft (a
1 forall a. Fractional a => a -> a -> a
/ a
60)
        sleft :: a
sleft         = a
mleft forall a. Fractional a => a -> a -> a
/ (a
1 forall a. Fractional a => a -> a -> a
/ a
3600)
    in forall a. a -> a -> a -> DMS a
DMS (forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
dint) (forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
mint) a
sleft
{-# INLINEABLE degreesToDMS #-}

instance PlaneAngle DMS where
    normalizeAngle :: forall a. (Floating a, Real a) => DMS a -> DMS a
normalizeAngle = forall a. (Real a, Fractional a) => Degrees a -> DMS a
degreesToDMS forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (ang :: * -> *) a.
(PlaneAngle ang, Floating a, Real a) =>
ang a -> ang a
normalizeAngle forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Fractional a => DMS a -> Degrees a
dmsToDegrees
    toRadians :: forall a. (Floating a, Real a) => DMS a -> Radians a
toRadians      = forall (ang :: * -> *) a.
(PlaneAngle ang, Floating a, Real a) =>
ang a -> Radians a
toRadians forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Fractional a => DMS a -> Degrees a
dmsToDegrees
    fromRadians :: forall a. (Floating a, Real a) => Radians a -> DMS a
fromRadians    = forall a. (Real a, Fractional a) => Degrees a -> DMS a
degreesToDMS forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (ang :: * -> *) a.
(PlaneAngle ang, Floating a, Real a) =>
Radians a -> ang a
fromRadians
    {-# INLINEABLE normalizeAngle #-}
    {-# INLINEABLE toRadians #-}
    {-# INLINEABLE fromRadians #-}

-- | An angle represented as degrees and minutes of arc.
data DM a = DM {
    forall a. DM a -> a
dmDeg :: !a
  , forall a. DM a -> a
dmMin :: !a
  } deriving stock ( DM a -> DM a -> Bool
forall a. Eq a => DM a -> DM a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DM a -> DM a -> Bool
$c/= :: forall a. Eq a => DM a -> DM a -> Bool
== :: DM a -> DM a -> Bool
$c== :: forall a. Eq a => DM a -> DM a -> Bool
Eq
                   , DM a -> DM a -> Bool
DM a -> DM a -> Ordering
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (DM a)
forall a. Ord a => DM a -> DM a -> Bool
forall a. Ord a => DM a -> DM a -> Ordering
forall a. Ord a => DM a -> DM a -> DM a
min :: DM a -> DM a -> DM a
$cmin :: forall a. Ord a => DM a -> DM a -> DM a
max :: DM a -> DM a -> DM a
$cmax :: forall a. Ord a => DM a -> DM a -> DM a
>= :: DM a -> DM a -> Bool
$c>= :: forall a. Ord a => DM a -> DM a -> Bool
> :: DM a -> DM a -> Bool
$c> :: forall a. Ord a => DM a -> DM a -> Bool
<= :: DM a -> DM a -> Bool
$c<= :: forall a. Ord a => DM a -> DM a -> Bool
< :: DM a -> DM a -> Bool
$c< :: forall a. Ord a => DM a -> DM a -> Bool
compare :: DM a -> DM a -> Ordering
$ccompare :: forall a. Ord a => DM a -> DM a -> Ordering
Ord
                   , Int -> DM a -> ShowS
forall a. Show a => Int -> DM a -> ShowS
forall a. Show a => [DM a] -> ShowS
forall a. Show a => DM a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DM a] -> ShowS
$cshowList :: forall a. Show a => [DM a] -> ShowS
show :: DM a -> String
$cshow :: forall a. Show a => DM a -> String
showsPrec :: Int -> DM a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> DM a -> ShowS
Show
                   , forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (DM a) x -> DM a
forall a x. DM a -> Rep (DM a) x
$cto :: forall a x. Rep (DM a) x -> DM a
$cfrom :: forall a x. DM a -> Rep (DM a) x
Generic
                   , DM a -> DataType
DM a -> Constr
forall {a}. Data a => Typeable (DM a)
forall a. Data a => DM a -> DataType
forall a. Data a => DM a -> Constr
forall a. Data a => (forall b. Data b => b -> b) -> DM a -> DM a
forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> DM a -> u
forall a u. Data a => (forall d. Data d => d -> u) -> DM a -> [u]
forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DM a -> r
forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DM a -> r
forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> DM a -> m (DM a)
forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> DM a -> m (DM a)
forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (DM a)
forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DM a -> c (DM a)
forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (DM a))
forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (DM a))
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (DM a)
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DM a -> c (DM a)
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (DM a))
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DM a -> m (DM a)
$cgmapMo :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> DM a -> m (DM a)
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> DM a -> m (DM a)
$cgmapMp :: forall a (m :: * -> *).
(Data a, MonadPlus m) =>
(forall d. Data d => d -> m d) -> DM a -> m (DM a)
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> DM a -> m (DM a)
$cgmapM :: forall a (m :: * -> *).
(Data a, Monad m) =>
(forall d. Data d => d -> m d) -> DM a -> m (DM a)
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> DM a -> u
$cgmapQi :: forall a u.
Data a =>
Int -> (forall d. Data d => d -> u) -> DM a -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> DM a -> [u]
$cgmapQ :: forall a u. Data a => (forall d. Data d => d -> u) -> DM a -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DM a -> r
$cgmapQr :: forall a r r'.
Data a =>
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DM a -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DM a -> r
$cgmapQl :: forall a r r'.
Data a =>
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DM a -> r
gmapT :: (forall b. Data b => b -> b) -> DM a -> DM a
$cgmapT :: forall a. Data a => (forall b. Data b => b -> b) -> DM a -> DM a
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (DM a))
$cdataCast2 :: forall a (t :: * -> * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (DM a))
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c (DM a))
$cdataCast1 :: forall a (t :: * -> *) (c :: * -> *).
(Data a, Typeable t) =>
(forall d. Data d => c (t d)) -> Maybe (c (DM a))
dataTypeOf :: DM a -> DataType
$cdataTypeOf :: forall a. Data a => DM a -> DataType
toConstr :: DM a -> Constr
$ctoConstr :: forall a. Data a => DM a -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (DM a)
$cgunfold :: forall a (c :: * -> *).
Data a =>
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c (DM a)
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DM a -> c (DM a)
$cgfoldl :: forall a (c :: * -> *).
Data a =>
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> DM a -> c (DM a)
Data
                   , DM a
forall a. a -> a -> Bounded a
forall a. Bounded a => DM a
maxBound :: DM a
$cmaxBound :: forall a. Bounded a => DM a
minBound :: DM a
$cminBound :: forall a. Bounded a => DM a
Bounded
                   , forall a b. a -> DM b -> DM a
forall a b. (a -> b) -> DM a -> DM b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: forall a b. a -> DM b -> DM a
$c<$ :: forall a b. a -> DM b -> DM a
fmap :: forall a b. (a -> b) -> DM a -> DM b
$cfmap :: forall a b. (a -> b) -> DM a -> DM b
Functor
                   )
    deriving anyclass (forall a. NFData a => DM a -> ()
forall a. (a -> ()) -> NFData a
rnf :: DM a -> ()
$crnf :: forall a. NFData a => DM a -> ()
NFData)

instance Applicative DM where
    pure :: forall a. a -> DM a
pure a
x = forall a. a -> a -> DM a
DM a
x a
x
    (DM a -> b
df a -> b
mf) <*> :: forall a b. DM (a -> b) -> DM a -> DM b
<*> (DM a
d a
m) = forall a. a -> a -> DM a
DM (a -> b
df a
d) (a -> b
mf a
m)

instance Monad DM where
    return :: forall a. a -> DM a
return = forall (f :: * -> *) a. Applicative f => a -> f a
pure
    (DM a
d a
m) >>= :: forall a b. DM a -> (a -> DM b) -> DM b
>>= a -> DM b
f = let DM b
d' b
_ = a -> DM b
f a
d
                         DM b
_ b
m' = a -> DM b
f a
m
                     in forall a. a -> a -> DM a
DM b
d' b
m'

instance MonadZip DM where
    mzipWith :: forall a b c. (a -> b -> c) -> DM a -> DM b -> DM c
mzipWith = forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2

instance MonadFix DM where
    mfix :: forall a. (a -> DM a) -> DM a
mfix a -> DM a
f = forall a. a -> a -> DM a
DM (let DM a
d a
_ = a -> DM a
f a
d in a
d)
                (let DM a
_ a
m = a -> DM a
f a
m in a
m)

instance Foldable DM where
    foldMap :: forall m a. Monoid m => (a -> m) -> DM a -> m
foldMap a -> m
f (DM a
d a
m) = a -> m
f a
d forall a. Semigroup a => a -> a -> a
<> a -> m
f a
m

instance Traversable DM where
    traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> DM a -> f (DM b)
traverse a -> f b
f (DM a
d a
m) = forall a. a -> a -> DM a
DM forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
d forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> a -> f b
f a
m

instance Distributive DM where
    distribute :: forall (f :: * -> *) a. Functor f => f (DM a) -> DM (f a)
distribute f (DM a)
f = forall a. a -> a -> DM a
DM (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(DM a
d a
_) -> a
d) f (DM a)
f)
                      (forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(DM a
_ a
m) -> a
m) f (DM a)
f)

-- | Convert DM to degrees. This does not normalize the angle.
dmToDegrees :: Fractional a => DM a -> Degrees a
dmToDegrees :: forall a. Fractional a => DM a -> Degrees a
dmToDegrees (DM a
d a
m) = forall a. a -> Degrees a
Degrees (a
d forall a. Num a => a -> a -> a
+ (a
m forall a. Num a => a -> a -> a
* (a
1 forall a. Fractional a => a -> a -> a
/ a
60)))
{-# INLINEABLE dmToDegrees #-}

-- | Convert degrees to DM. This does not normalize the angle.
degreesToDM :: (Fractional a, Real a) => Degrees a -> DM a
degreesToDM :: forall a. (Fractional a, Real a) => Degrees a -> DM a
degreesToDM (Degrees a
d) =
    let (Integer
dint, a
m) = forall a b. (Real a, Integral b) => a -> a -> (b, a)
divMod' a
d a
1
    in forall a. a -> a -> DM a
DM (forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
dint) (a
m forall a. Fractional a => a -> a -> a
/ (a
1 forall a. Fractional a => a -> a -> a
/ a
60))
{-# INLINEABLE degreesToDM #-}

instance PlaneAngle DM where
    normalizeAngle :: forall a. (Floating a, Real a) => DM a -> DM a
normalizeAngle = forall a. (Fractional a, Real a) => Degrees a -> DM a
degreesToDM forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (ang :: * -> *) a.
(PlaneAngle ang, Floating a, Real a) =>
ang a -> ang a
normalizeAngle forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Fractional a => DM a -> Degrees a
dmToDegrees
    toRadians :: forall a. (Floating a, Real a) => DM a -> Radians a
toRadians      = forall (ang :: * -> *) a.
(PlaneAngle ang, Floating a, Real a) =>
ang a -> Radians a
toRadians forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Fractional a => DM a -> Degrees a
dmToDegrees
    fromRadians :: forall a. (Floating a, Real a) => Radians a -> DM a
fromRadians    = forall a. (Fractional a, Real a) => Degrees a -> DM a
degreesToDM forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (ang :: * -> *) a.
(PlaneAngle ang, Floating a, Real a) =>
Radians a -> ang a
fromRadians
    {-# INLINEABLE normalizeAngle #-}
    {-# INLINEABLE toRadians #-}
    {-# INLINEABLE fromRadians #-}