module Data.Geo.Coordinate.Seconds(
Seconds
, HasSeconds(..)
, nSeconds
) where
import Prelude(Double, Bool(..), Eq, Show(..), Ord(..), id, (&&), (++), showParen, showString)
import Data.Maybe(Maybe(..))
import Control.Lens(Prism', Lens', prism')
import Text.Printf(printf)
newtype Seconds =
Seconds Double
deriving (Eq, Ord)
instance Show Seconds where
showsPrec n (Seconds d) =
showParen (n > 10) (showString ("Seconds " ++ printf "%0.4f" d))
nSeconds ::
Prism' Double Seconds
nSeconds =
prism'
(\(Seconds d) -> d)
(\d -> case d >= 0 && d < 60 of
True -> Just (Seconds d)
False -> Nothing)
class HasSeconds t where
seconds ::
Lens' t Seconds
instance HasSeconds Seconds where
seconds =
id