summaryrefslogtreecommitdiff
path: root/Network/API/Telegram/Bot/Object/Update/Message/Content/Location.hs
blob: a85ca0566ef5b3fd12dccb688aa7ad5a5b7862b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Network.API.Telegram.Bot.Object.Update.Message.Content.Location (Location (..)) where

import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), object, withObject, (.:), (.=))
import "base" Control.Applicative ((<*>))
import "base" Data.Function (($))
import "base" Data.Functor ((<$>))
import "base" GHC.Float (Float)
import "base" Text.Show (Show)

data Location = Location Float Float
	deriving Show

instance FromJSON Location where
	parseJSON = withObject "Location" $ \v -> Location
		<$> v .: "longitude" <*> v .: "latitude"

instance ToJSON Location where
	toJSON (Location latitude longitude) = object
		["latitude" .= latitude, "longitude" .= longitude]