summaryrefslogtreecommitdiff
path: root/Network/API/Telegram/Bot/Object/Update/Message/Content/Location.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Network/API/Telegram/Bot/Object/Update/Message/Content/Location.hs')
-rw-r--r--Network/API/Telegram/Bot/Object/Update/Message/Content/Location.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/Network/API/Telegram/Bot/Object/Update/Message/Content/Location.hs b/Network/API/Telegram/Bot/Object/Update/Message/Content/Location.hs
new file mode 100644
index 0000000..a85ca05
--- /dev/null
+++ b/Network/API/Telegram/Bot/Object/Update/Message/Content/Location.hs
@@ -0,0 +1,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]