coordinate-0.0.18: A representation of latitude and longitude

Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Geo.Coordinate.Minutes

Synopsis

Documentation

data Minutes Source

Instances

Eq Minutes 
Ord Minutes 
Show Minutes 
AsMinutes p f Minutes 
(Choice p, Applicative f) => AsCoordinate p f (Double, (DegreesLongitude, Minutes, Seconds)) 
(Choice p, Applicative f) => AsCoordinate p f ((DegreesLatitude, Minutes, Seconds), Double) 
(Profunctor p, Functor f) => AsCoordinate p f ((DegreesLongitude, Minutes, Seconds), (DegreesLatitude, Minutes, Seconds)) 
(Profunctor p, Functor f) => AsCoordinate p f ((DegreesLatitude, Minutes, Seconds), (DegreesLongitude, Minutes, Seconds)) 
(Profunctor p, Functor f) => AsCoordinate p f ((DegreesLongitude, Minutes, Seconds), Latitude) 
(Profunctor p, Functor f) => AsCoordinate p f (Latitude, (DegreesLongitude, Minutes, Seconds)) 
(Profunctor p, Functor f) => AsCoordinate p f (Longitude, (DegreesLatitude, Minutes, Seconds)) 
(Profunctor p, Functor f) => AsCoordinate p f ((DegreesLatitude, Minutes, Seconds), Longitude) 
(Profunctor p, Functor f) => AsLongitude p f (DegreesLongitude, Minutes, Seconds)

An isomorphism on the triple of degrees longitude, minutes, seconds to a longitude.

>>> do deg <- (7 :: Int) ^? _DegreesLongitude; min <- (7 :: Int) ^? _Minutes; sec <- (7 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude
Just (Longitude (DegreesLongitude 7) (Minutes 7) (Seconds 7.0000))
>>> do deg <- (179 :: Int) ^? _DegreesLongitude; min <- (59 :: Int) ^? _Minutes; sec <- (59 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude
Just (Longitude (DegreesLongitude 179) (Minutes 59) (Seconds 59.0000))
>>> do deg <- (-7 :: Int) ^? _DegreesLongitude; min <- (7 :: Int) ^? _Minutes; sec <- (7 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude
Just (Longitude (DegreesLongitude (-7)) (Minutes 7) (Seconds 7.0000))
>>> do deg <- (-179 :: Int) ^? _DegreesLongitude; min <- (59 :: Int) ^? _Minutes; sec <- (59 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude
Just (Longitude (DegreesLongitude (-179)) (Minutes 59) (Seconds 59.0000))
>>> do deg <- (180 :: Int) ^? _DegreesLongitude; min <- (59 :: Int) ^? _Minutes; sec <- (59 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude
Nothing
>>> do deg <- (179 :: Int) ^? _DegreesLongitude; min <- (60 :: Int) ^? _Minutes; sec <- (59 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude
Nothing
>>> do deg <- (179 :: Int) ^? _DegreesLongitude; min <- (59 :: Int) ^? _Minutes; sec <- (60 :: Double) ^? _Seconds; (deg, min, sec) ^? _Longitude :: Maybe Longitude
Nothing
>>> fmap (\x -> _Longitude # x :: (DegreesLongitude, Minutes, Seconds))  ((7 :: Double) ^? _Longitude :: Maybe Longitude)
Just (DegreesLongitude 7,Minutes 0,Seconds 0.0000)
>>> fmap (\x -> _Longitude # x :: (DegreesLongitude, Minutes, Seconds))  ((7.12 :: Double) ^? _Longitude :: Maybe Longitude)
Just (DegreesLongitude 7,Minutes 7,Seconds 12.0000)
(Profunctor p, Functor f) => AsLatitude p f (DegreesLatitude, Minutes, Seconds)

An isomorphism on the triple of degrees latitude, minutes, seconds to a latitude.

>>> do deg <- (7 :: Int) ^? _DegreesLatitude; min <- (7 :: Int) ^? _Minutes; sec <- (7 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude
Just (Latitude (DegreesLatitude 7) (Minutes 7) (Seconds 7.0000))
>>> do deg <- (89 :: Int) ^? _DegreesLatitude; min <- (59 :: Int) ^? _Minutes; sec <- (59 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude
Just (Latitude (DegreesLatitude 89) (Minutes 59) (Seconds 59.0000))
>>> do deg <- (-7 :: Int) ^? _DegreesLatitude; min <- (7 :: Int) ^? _Minutes; sec <- (7 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude
Just (Latitude (DegreesLatitude (-7)) (Minutes 7) (Seconds 7.0000))
>>> do deg <- (-89 :: Int) ^? _DegreesLatitude; min <- (59 :: Int) ^? _Minutes; sec <- (59 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude
Just (Latitude (DegreesLatitude (-89)) (Minutes 59) (Seconds 59.0000))
>>> do deg <- (90 :: Int) ^? _DegreesLatitude; min <- (59 :: Int) ^? _Minutes; sec <- (59 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude
Nothing
>>> do deg <- (89 :: Int) ^? _DegreesLatitude; min <- (60 :: Int) ^? _Minutes; sec <- (59 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude
Nothing
>>> do deg <- (89 :: Int) ^? _DegreesLatitude; min <- (59 :: Int) ^? _Minutes; sec <- (60 :: Double) ^? _Seconds; (deg, min, sec) ^? _Latitude :: Maybe Latitude
Nothing
>>> fmap (\x -> _Latitude # x :: (DegreesLatitude, Minutes, Seconds))  ((7 :: Double) ^? _Latitude :: Maybe Latitude)
Just (DegreesLatitude 7,Minutes 0,Seconds 0.0000)
>>> fmap (\x -> _Latitude # x :: (DegreesLatitude, Minutes, Seconds))  ((7.12 :: Double) ^? _Latitude :: Maybe Latitude)
Just (DegreesLatitude 7,Minutes 7,Seconds 12.0000)

class AsMinutes p f s where Source

Minimal complete definition

Nothing

Methods

_Minutes :: Optic' p f s Minutes Source

Instances

(Choice p, Applicative f) => AsMinutes p f Int

A prism on minutes to an integer between 0 and 59 inclusive.

>>> (7 :: Int) ^? _Minutes
Just (Minutes 7)
>>> (0 :: Int) ^? _Minutes
Just (Minutes 0)
>>> (59 :: Int) ^? _Minutes
Just (Minutes 59)
>>> (60 :: Int) ^? _Minutes
Nothing
all (\m -> _Minutes # m == (n :: Int)) (n ^? _Minutes)
AsMinutes p f Minutes 
((~) (* -> * -> *) p (->), Functor f) => AsMinutes p f Longitude 
((~) (* -> * -> *) p (->), Functor f) => AsMinutes p f Latitude 

remMinutes :: Int -> Minutes Source

Setting a value >= 60 will get that value (rem 60).

>>> remMinutes 7
Minutes 7
>>> remMinutes 0
Minutes 0
>>> remMinutes 60
Minutes 0
>>> remMinutes 1
Minutes 1
>>> remMinutes 59
Minutes 59