packages feed

geodetic-types-0.0.2: src/Geodetics/Types/LatLon.hs

{-# LANGUAGE NoImplicitPrelude #-}

module Geodetics.Types.LatLon(
  LatLon(..)
, HasLatLon(..)
, AsLatLon(..)
, ManyLatLon(..)
, GetLatLon(..)
, SetLatLon(..)
, FoldLatLon(..)
, IsLatLon(..)  
) where
 
import Control.Category(id)
import Control.Lens(Lens', Prism', Traversal', Getter, Setter', Fold, Iso')
import Data.Eq(Eq)
import Data.Functor(fmap)
import Data.Ord(Ord)
import Geodetics.Types.Latitude(Latitude, HasLatitude(latitude))
import Geodetics.Types.Longitude(Longitude, HasLongitude(longitude))
import Prelude(Show)

data LatLon =
  LatLon
    Latitude
    Longitude
  deriving (Eq, Ord, Show)

instance HasLatitude LatLon where
  latitude f (LatLon lt ln) =
    fmap (\lt' -> LatLon lt' ln) (f lt)

instance HasLongitude LatLon where
  longitude f (LatLon lt ln) =
    fmap (\ln' -> LatLon lt ln') (f ln)

class HasLatLon a where
  latlon ::
    Lens' a LatLon

instance HasLatLon LatLon where
  latlon =
    id

class ManyLatLon a => AsLatLon a where
  _LatLon ::
    Prism' a LatLon

instance AsLatLon LatLon where
  _LatLon =
    id

class (FoldLatLon a, SetLatLon a) => ManyLatLon a where
  _ManyLatLon ::
    Traversal' a LatLon

instance ManyLatLon LatLon where
  _ManyLatLon =
    id

class FoldLatLon a => GetLatLon a where
  _GetLatLon ::
    Getter a LatLon
    
instance GetLatLon LatLon where
  _GetLatLon =
    id

class SetLatLon a where
  _SetLatLon ::
    Setter' a LatLon
    
instance SetLatLon LatLon where
  _SetLatLon =
    id

class FoldLatLon a where
  _FoldLatLon ::
    Fold a LatLon
    
instance FoldLatLon LatLon where
  _FoldLatLon =
    id

class (HasLatLon a, AsLatLon a) => IsLatLon a where
  _IsLatLon ::
    Iso' a LatLon
    
instance IsLatLon LatLon where
  _IsLatLon =
    id