coordinate-0.0.21: A representation of latitude and longitude

Safe HaskellNone
LanguageHaskell2010

Data.Geo.Coordinate.Minutes

Synopsis

Documentation

data Minutes Source

Instances

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

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) Source

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 Source

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 Source 
((~) (* -> * -> *) p (->), Functor f) => AsMinutes p f Longitude Source 
((~) (* -> * -> *) p (->), Functor f) => AsMinutes p f Latitude Source 
((~) (* -> * -> *) p (->), Applicative f) => AsMinutes p f Coordinate Source 

modMinutes :: Int -> Minutes Source

Setting a value within the range 0 and 60 using modulo arithmetic.

>>> modMinutes 7
Minutes 7
>>> modMinutes 0
Minutes 0
>>> modMinutes 60
Minutes 0
>>> modMinutes 1
Minutes 1
>>> modMinutes 59
Minutes 59 
>>> modMinutes 61
Minutes 1
>>> modMinutes (-1)
Minutes 59