packages feed

telega 0.2.6 → 0.2.7

raw patch · 22 files changed

+347/−137 lines, 22 files

Files

CHANGELOG.md view
@@ -133,3 +133,15 @@ * Add `Sender` field into `Callback` datatype to understand from whom action goes * Change endpoint for `Edit`ing `Keyboard` object, remove `Edit` `Text :&: Keyboard` instance * Replace `Group` and `Supergroup` constructors by including `Group` field in `Origin` datatype++# 0.2.7+* Define `Name` module to make `Accessible` instances for `Nick`/`First`/`Last` names+* Define `Duration` newtype to avoid vague raw `Text` in `Audio`, `Video` and `Voice` objects+* Define `Language` newtype to replace raw `Text` in `Sender` object+* Remove `URI` newtype from `File` to `Audio`, `Video`, `Document` and `Voice` objects+* Define `Identifiable` instances for `URI`, `Audio`, `Video`, `Document` and `Voice` objects+* Define `Accessible` and `Identifiable` instances for `Member` object+* Define `Accessible` instance for newtypes to not use generated accessors records+* Move `Caption`, `Duration` and `URI` modules into `Special` submodule+* Define `MIME` newtype in `Special` submodule to replace vague `Text`+* Rename `Size` to `Photosize` and move its content to `Photo` module
Network/API/Telegram/Bot/Object.hs view
@@ -2,4 +2,5 @@  import Network.API.Telegram.Bot.Object.Update as Exports import Network.API.Telegram.Bot.Object.Sender as Exports+import Network.API.Telegram.Bot.Object.Name as Exports import Network.API.Telegram.Bot.Object.Member as Exports
+ Network/API/Telegram/Bot/Object/Language.hs view
@@ -0,0 +1,22 @@+module Network.API.Telegram.Bot.Object.Language (Language (..)) where++import "aeson" Data.Aeson (FromJSON (parseJSON)+	, ToJSON (toJSON), Value (String), withText)+import "base" Control.Applicative (pure)+import "base" Data.Function ((.))+import "base" Data.Functor ((<$>))+import "base" Text.Show (Show)+import "text" Data.Text (Text)++import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))++newtype Language = Language Text deriving Show++instance Accessible Text Language where+	access f (Language txt) = (\txt' -> Language txt') <$> f txt++instance FromJSON Language where+	parseJSON = withText "Language" (pure . Language)++instance ToJSON Language where+	toJSON (Language txt) = String txt
Network/API/Telegram/Bot/Object/Member.hs view
@@ -18,6 +18,8 @@ import "text" Data.Text (Text)  import Network.API.Telegram.Bot.Object.Sender (Sender)+import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))+import Network.API.Telegram.Bot.Property.Identifiable (Identifiable (Identificator, ident)) import Network.API.Telegram.Bot.Property.Persistable (Persistable (Payload, Returning, payload, endpoint)) import Network.API.Telegram.Bot.Utils (field) @@ -29,6 +31,23 @@ 	| Left Sender 	| Kicked Sender Int 	deriving Show++instance Accessible Sender Member where+	access f (Creator sender) = (\sender' -> Creator sender') <$> f sender+	access f (Administrator sender cbe powers) = (\sender' -> Administrator sender' cbe powers) <$> f sender+	access f (Member sender) = (\sender' -> Member sender') <$> f sender+	access f (Restricted sender restrictions until) = (\sender' -> Restricted sender' restrictions until) <$> f sender+	access f (Left sender) = (\sender' -> Left sender') <$> f sender+	access f (Kicked sender until) = (\sender' -> Kicked sender' until) <$> f sender++instance Identifiable Member where+	type Identificator Member = Sender+	ident (Creator sender) = sender+	ident (Administrator sender _ _) = sender+	ident (Member sender) = sender+	ident (Restricted sender _ _) = sender+	ident (Left sender) = sender+	ident (Kicked sender _) = sender  instance FromJSON Member where 	parseJSON = withObject "Member" $ \v -> v .: "status" >>= \case
+ Network/API/Telegram/Bot/Object/Name.hs view
@@ -0,0 +1,62 @@+module Network.API.Telegram.Bot.Object.Name+	(Name (..), First (..), Last (..), Nick (..)) where++import "aeson" Data.Aeson (FromJSON (parseJSON)+	, ToJSON (toJSON), Value (String), withText)+import "base" Control.Applicative (pure)+import "base" Data.Function ((.), ($))+import "base" Data.Functor ((<$>))+import "base" Text.Show (Show)+import "text" Data.Text (Text)++import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))++newtype Name = Name Text deriving Show++instance Accessible Text Name where+	access f (Name txt) = (\txt' -> Name txt') <$> f txt++instance FromJSON Name where+	parseJSON = withText "Name" (pure . Name)++instance ToJSON Name where+	toJSON (Name txt) = String txt++data First a where First :: Name -> First Name++deriving instance Show a => Show (First a)++instance Accessible Text (First a) where+	access f (First (Name txt)) = (\txt' -> First $ Name txt') <$> f txt++instance FromJSON (First Name) where+	parseJSON o = First <$> parseJSON o++instance ToJSON (First Name) where+	toJSON (First name) = toJSON name++data Last a where Last :: Name -> Last Name++deriving instance Show a => Show (Last a)++instance Accessible Text (Last a) where+	access f (Last (Name txt)) = (\txt' -> Last $ Name txt') <$> f txt++instance FromJSON (Last Name) where+	parseJSON o = Last <$> parseJSON o++instance ToJSON (Last Name) where+	toJSON (Last name) = toJSON name++data Nick a where Nick :: Name -> Nick Name++deriving instance Show a => Show (Nick a)++instance Accessible Text (Nick a) where+	access f (Nick (Name txt)) = (\txt' -> Nick $ Name txt') <$> f txt++instance FromJSON (Nick Name) where+	parseJSON o = Nick <$> parseJSON o++instance ToJSON (Nick Name) where+	toJSON (Nick name) = toJSON name
Network/API/Telegram/Bot/Object/Sender.hs view
@@ -1,4 +1,4 @@-module Network.API.Telegram.Bot.Object.Sender (Sender (..), nickname, firstname, lastname) where+module Network.API.Telegram.Bot.Object.Sender (Sender (..)) where  import "aeson" Data.Aeson (FromJSON (parseJSON), Object, withObject, (.:), (.:?)) import "aeson" Data.Aeson.Types (Parser)@@ -11,14 +11,15 @@ import "base" Data.Functor ((<$>)) import "base" Data.Maybe (Maybe) import "base" Text.Show (Show)-import "lens" Control.Lens (Lens')-import "text" Data.Text (Text) +import Network.API.Telegram.Bot.Object.Language (Language)+import Network.API.Telegram.Bot.Object.Name (Name, First, Last, Nick)+import Network.API.Telegram.Bot.Property.Accessible (Accessible (access)) import Network.API.Telegram.Bot.Property.Identifiable (Identifiable (Identificator, ident))  data Sender-	= Bot Int (Maybe Text) Text (Maybe Text) (Maybe Text)-	| Human Int (Maybe Text) Text (Maybe Text) (Maybe Text)+	= Bot Int (Maybe (Nick Name)) (First Name) (Maybe (Last Name)) (Maybe Language)+	| Human Int (Maybe (Nick Name)) (First Name) (Maybe (Last Name)) (Maybe Language) 	deriving Show  instance Eq Sender where@@ -31,8 +32,24 @@ 	ident (Bot i _ _ _ _) = i 	ident (Human i _ _ _ _) = i -type Whom = Int -> Maybe Text -> Text -> Maybe Text -> Maybe Text -> Sender+instance Accessible (First Name) Sender where+	access f (Bot uid nn fn ln lng) = (\fn' -> Bot uid nn fn' ln lng) <$> f fn+	access f (Human uid nn fn ln lng) = (\fn' -> Human uid nn fn' ln lng) <$> f fn +instance Accessible (Maybe (Last Name)) Sender where+	access f (Bot uid nn fn ln lng) = (\ln' -> Bot uid nn fn ln' lng) <$> f ln+	access f (Human uid nn fn ln lng) = (\ln' -> Human uid nn fn ln' lng) <$> f ln++instance Accessible (Maybe (Nick Name)) Sender where+	access f (Bot uid nn fn ln lng) = (\nn' -> Bot uid nn' fn ln lng) <$> f nn+	access f (Human uid nn fn ln lng) = (\nn' -> Human uid nn' fn ln lng) <$> f nn++instance Accessible (Maybe Language) Sender where+	access f (Bot uid nn fn ln lng) = (\lng' -> Bot uid nn fn ln lng') <$> f lng+	access f (Human uid nn fn ln lng) = (\lng' -> Human uid nn fn ln lng') <$> f lng++type Whom = Int -> Maybe (Nick Name) -> First Name -> Maybe (Last Name) -> Maybe Language -> Sender+ instance FromJSON Sender where 	parseJSON = withObject "Sender" $ \v -> v .: "is_bot" 		>>= bool (sender v Human) (sender v Bot) where@@ -41,15 +58,3 @@ 		sender v f = f <$> v .: "id" <*> v .:? "username" 			<*> v .: "first_name" <*> v .:? "last_name" 			<*> v .:? "language_code"--nickname :: Lens' Sender (Maybe Text)-nickname f (Bot uid nn fn ln lng) = (\nn' -> Bot uid nn' fn ln lng) <$> f nn-nickname f (Human uid nn fn ln lng) = (\nn' -> Human uid nn' fn ln lng) <$> f nn--firstname :: Lens' Sender Text-firstname f (Bot uid nn fn ln lng) = (\fn' -> Bot uid nn fn' ln lng) <$> f fn-firstname f (Human uid nn fn ln lng) = (\fn' -> Human uid nn fn' ln lng) <$> f fn--lastname :: Lens' Sender (Maybe Text)-lastname f (Bot uid nn fn ln lng) = (\ln' -> Bot uid nn fn ln' lng) <$> f ln-lastname f (Human uid nn fn ln lng) = (\ln' -> Human uid nn fn ln' lng) <$> f ln
Network/API/Telegram/Bot/Object/Update/Message.hs view
@@ -106,57 +106,57 @@ 	endpoint _ = "sendMessage"  instance Persistable (Send Audio) where-	type Payload (Send Audio) = Send (URI :&: Audio)+	type Payload (Send Audio) = Send Audio 	type Returning (Send Audio) = Message-	payload (Send chat_id (uri :&: Audio duration performer title mime_type file_size)) = field "file_id" uri+	payload (Send chat_id (Audio uri duration performer title mime_type file_size)) = field "file_id" uri 		<> field "chat_id" chat_id <> field "duration" duration <> field "performer" performer 		<> field "title" title <> field "mime_type" mime_type <> field "file_size" file_size 	endpoint _ = "sendAudio"  instance Persistable (Send (Caption :&: Audio)) where-	type Payload (Send (Caption :&: Audio)) = Send (Caption :&: URI :&: Audio)+	type Payload (Send (Caption :&: Audio)) = Send (Caption :&: Audio) 	type Returning (Send (Caption :&: Audio)) = Message 	payload (Send chat_id (caption :&: audio)) = payload (Send chat_id audio) <> field "caption" caption 	endpoint _ = "sendAudio"  instance Persistable (Send Document) where-	type Payload (Send Document) = Send (URI :&: Document)+	type Payload (Send Document) = Send Document 	type Returning (Send Document) = Message-	payload (Send chat_id (uri :&: Document file_name mime_type file_size)) = field "file_id" uri+	payload (Send chat_id (Document uri file_name mime_type file_size)) = field "file_id" uri 		<> field "chat_id" chat_id <> field "file_name" file_name 		<> field "mime_type" mime_type <> field "file_size" file_size 	endpoint _ = "sendDocument"  instance Persistable (Send (Caption :&: Document)) where-	type Payload (Send (Caption :&: Document)) = Send (Caption :&: URI :&: Document)+	type Payload (Send (Caption :&: Document)) = Send (Caption :&: Document) 	type Returning (Send (Caption :&: Document)) = Message 	payload (Send chat_id (caption :&: document)) = payload (Send chat_id document) <> field "caption" caption 	endpoint _ = "sendDocument"  instance Persistable (Send Video) where-	type Payload (Send Video) = Send (URI :&: Video)+	type Payload (Send Video) = Send Video 	type Returning (Send Video) = Message-	payload (Send chat_id (uri :&: Video width height duration mime_type file_size)) = field "file_id" uri+	payload (Send chat_id (Video uri width height duration mime_type file_size)) = field "file_id" uri 		<> field "chat_id" chat_id <> field "duration" duration <> field "width" width 		<> field "height" height <> field "mime_type" mime_type <> field "file_size" file_size 	endpoint _ = "sendVideo"  instance Persistable (Send (Caption :&: Video)) where-	type Payload (Send (Caption :&: Video)) = Send (Caption :&: URI :&: Video)+	type Payload (Send (Caption :&: Video)) = Send (Caption :&: Video) 	type Returning (Send (Caption :&: Video)) = Message 	payload (Send chat_id (caption :&: video)) = payload (Send chat_id video) <> field "caption" caption 	endpoint _ = "sendVideo"  instance Persistable (Send Voice) where-	type Payload (Send Voice) = Send (URI :&: Voice)+	type Payload (Send Voice) = Send Voice 	type Returning (Send Voice) = Message-	payload (Send chat_id (uri :&: Voice duration mime_type file_size)) = field "file_id" uri+	payload (Send chat_id (Voice uri duration mime_type file_size)) = field "file_id" uri 		<> field "chat_id" chat_id <> field "duration" duration 		<> field "mime_type" mime_type <> field "file_size" file_size 	endpoint _ = "sendVoice"  instance Persistable (Send (Caption :&: Voice)) where-	type Payload (Send (Caption :&: Voice)) = Send (Caption :&: URI :&: Voice)+	type Payload (Send (Caption :&: Voice)) = Send (Caption :&: Voice) 	type Returning (Send (Caption :&: Voice)) = Message 	payload (Send chat_id (caption :&: voice)) = payload (Send chat_id voice) <> field "caption" caption 	endpoint _ = "sendVoice"
Network/API/Telegram/Bot/Object/Update/Message/Content/File.hs view
@@ -1,43 +1,32 @@ module Network.API.Telegram.Bot.Object.Update.Message.Content.File (File (..), module Exports) where  import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Audio as Exports-import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption as Exports import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Document as Exports import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Photo as Exports-import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Size as Exports-import Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI as Exports import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Video as Exports import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Voice as Exports+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Caption as Exports+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Duration as Exports+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.URI as Exports  import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:))-import "base" Control.Applicative ((<*>), (<|>))-import "base" Data.Bool (Bool (False))-import "base" Data.Eq (Eq ((==)))-import "base" Control.Monad ((>>=))+import "base" Control.Applicative ((<|>)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>)) import "base" Text.Show (Show)  data File-	= Audiofile URI Audio-	| Videofile URI Video-	| General URI Document-	| Voicerecord URI Voice-	| Photography [Size]+	= Audiofile Audio+	| Videofile Video+	| General Document+	| Voicerecord Voice+	| Photography [Photosize] 	deriving Show -instance Eq File where-	Audiofile i _ == Audiofile i' _ = i == i'-	Videofile i _ == Videofile i' _ = i == i'-	General i _ == General i' _ = i == i'-	Voicerecord i _ == Voicerecord i' _ = i == i'-	Photography ss == Photography ss' = ss == ss'-	_ == _ = False- instance FromJSON File where 	parseJSON = withObject "Message" $ \v -> 		(Photography <$> v .: "photo") <|>-		(Audiofile <$> (v .: "audio" >>= parseJSON) <*> v .: "audio") <|>-		(General <$> (v .: "document" >>= parseJSON) <*> v .: "document") <|>-		(Videofile <$> (v .: "video" >>= parseJSON) <*> v .: "video") <|>-		(Voicerecord <$> (v .: "voice" >>= parseJSON) <*> v .: "voice")+		(Audiofile <$> v .: "audio") <|>+		(General <$> v .: "document") <|>+		(Videofile <$> v .: "video") <|>+		(Voicerecord <$> v .: "voice")
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Audio.hs view
@@ -9,10 +9,19 @@ import "base" Text.Show (Show) import "text" Data.Text (Text) -data Audio = Audio Int (Maybe Text) (Maybe Text) (Maybe Text) (Maybe Int)-	deriving Show+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.URI (URI)+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Duration (Duration)+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.MIME (MIME)+import Network.API.Telegram.Bot.Property (Identifiable (Identificator, ident)) +data Audio = Audio URI Duration (Maybe Text) (Maybe Text) (Maybe MIME) (Maybe Int) deriving Show++instance Identifiable Audio where+	type Identificator Audio = URI+	ident (Audio uri _ _ _ _ _) = uri+ instance FromJSON Audio where 	parseJSON = withObject "Audio" $ \v -> Audio-		<$> v .: "duration" <*> v .:? "performer" <*> v .:? "title"+		<$> v .: "file_id" <*> v .: "duration"+		<*> v .:? "performer" <*> v .:? "title" 		<*> v .:? "mime_type" <*> v .:? "file_size"
− Network/API/Telegram/Bot/Object/Update/Message/Content/File/Caption.hs
@@ -1,16 +0,0 @@-module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption (Caption (..)) where--import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (String), withText)-import "base" Control.Applicative (pure)-import "base" Data.Function ((.))-import "base" Text.Show (Show)-import "text" Data.Text (Text)--newtype Caption = Caption Text-	deriving Show--instance FromJSON Caption where-	parseJSON = withText "Caption" (pure . Caption)--instance ToJSON Caption where-	toJSON (Caption txt) = String txt
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Document.hs view
@@ -1,6 +1,6 @@ module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Document (Document (..)) where -import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:?))+import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:), (.:?)) import "base" Control.Applicative ((<*>)) import "base" Data.Int (Int) import "base" Data.Maybe (Maybe)@@ -9,9 +9,17 @@ import "base" Text.Show (Show) import "text" Data.Text (Text) -data Document = Document (Maybe Text) (Maybe Text) (Maybe Int)-	deriving Show+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.MIME (MIME)+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.URI (URI)+import Network.API.Telegram.Bot.Property (Identifiable (Identificator, ident)) +data Document = Document URI (Maybe Text) (Maybe MIME) (Maybe Int) deriving Show++instance Identifiable Document where+	type Identificator Document = URI+	ident (Document uri _ _ _) = uri+ instance FromJSON Document where 	parseJSON = withObject "Document" $ \v -> Document-		<$> v .:? "file_name" <*> v .:? "mime_type" <*> v .:? "file_size"+		<$> v .: "file_id" <*>  v .:? "file_name"+		<*> v .:? "mime_type" <*> v .:? "file_size"
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Photo.hs view
@@ -1,3 +1,28 @@-module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Photo (Photo) where+module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Photo (Photo, Photosize) where +import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:))+import "base" Control.Applicative ((<*>))+import "base" Data.Eq (Eq ((==)))+import "base" Data.Int (Int)+import "base" Data.Function (($))+import "base" Data.Functor ((<$>))+import "base" Data.Maybe (Maybe)+import "base" Text.Show (Show)+import "text" Data.Text (Text)++import Network.API.Telegram.Bot.Property.Identifiable (Identifiable (Identificator, ident))+ data Photo++data Photosize = Photosize Text Int Int (Maybe Int) deriving Show++instance Eq Photosize where+	s == s' = ident s == ident s'++instance Identifiable Photosize where+	type Identificator Photosize = Text+	ident (Photosize file_id _ _ _) = file_id++instance FromJSON Photosize where+	parseJSON = withObject "Photosize" $ \v -> Photosize <$> v .: "file_id"+		<*> v .: "width" <*> v .: "height" <*> v .: "file_size"
− Network/API/Telegram/Bot/Object/Update/Message/Content/File/Size.hs
@@ -1,26 +0,0 @@-module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Size (Size (..)) where--import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:))-import "base" Control.Applicative ((<*>))-import "base" Data.Eq (Eq ((==)))-import "base" Data.Int (Int)-import "base" Data.Function (($))-import "base" Data.Functor ((<$>))-import "base" Data.Maybe (Maybe)-import "base" Text.Show (Show)-import "text" Data.Text (Text)--import Network.API.Telegram.Bot.Property.Identifiable (Identifiable (Identificator, ident))--data Size = Size Text Int Int (Maybe Int) deriving Show--instance Eq Size where-	s == s' = ident s == ident s'--instance Identifiable Size where-	type Identificator Size = Text-	ident (Size file_id _ _ _) = file_id--instance FromJSON Size where-	parseJSON = withObject "Size" $ \v -> Size <$> v .: "file_id"-		<*> v .: "width" <*> v .: "height" <*> v .: "file_size"
+ Network/API/Telegram/Bot/Object/Update/Message/Content/File/Special/Caption.hs view
@@ -0,0 +1,21 @@+module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Caption (Caption (..)) where++import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (String), withText)+import "base" Control.Applicative (pure)+import "base" Data.Function ((.))+import "base" Data.Functor ((<$>))+import "base" Text.Show (Show)+import "text" Data.Text (Text)++import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))++newtype Caption = Caption Text deriving Show++instance Accessible Text Caption where+	access f (Caption txt) = (\txt' -> Caption txt') <$> f txt++instance FromJSON Caption where+	parseJSON = withText "Caption" (pure . Caption)++instance ToJSON Caption where+	toJSON (Caption txt) = String txt
+ Network/API/Telegram/Bot/Object/Update/Message/Content/File/Special/Duration.hs view
@@ -0,0 +1,19 @@+module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Duration (Duration) where++import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON))+import "base" Data.Functor ((<$>))+import "base" Data.Int (Int)+import "base" Text.Show (Show)++import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))++newtype Duration = Duration Int deriving Show++instance Accessible Int Duration where+	access f (Duration int) = (\int' -> Duration int') <$> f int++instance FromJSON Duration where+	parseJSON o = Duration <$> parseJSON o++instance ToJSON Duration where+	toJSON (Duration d) = toJSON d
+ Network/API/Telegram/Bot/Object/Update/Message/Content/File/Special/MIME.hs view
@@ -0,0 +1,21 @@+module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.MIME (MIME (..)) where++import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (String), withText)+import "base" Control.Applicative (pure)+import "base" Data.Function ((.))+import "base" Data.Functor ((<$>))+import "base" Text.Show (Show)+import "text" Data.Text (Text)++import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))++newtype MIME = MIME Text deriving Show++instance Accessible Text MIME where+	access f (MIME txt) = (\txt' -> MIME txt') <$> f txt++instance FromJSON MIME where+	parseJSON = withText "MIME" (pure . MIME)++instance ToJSON MIME where+	toJSON (MIME txt) = String txt
+ Network/API/Telegram/Bot/Object/Update/Message/Content/File/Special/URI.hs view
@@ -0,0 +1,27 @@+module Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.URI (URI (..)) where++import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (String), withText)+import "base" Control.Applicative (pure)+import "base" Data.Eq (Eq)+import "base" Data.Function ((.))+import "base" Data.Functor ((<$>))+import "base" Text.Show (Show)+import "text" Data.Text (Text)++import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))+import Network.API.Telegram.Bot.Property (Identifiable (Identificator, ident))++newtype URI = URI Text deriving (Eq, Show)++instance Accessible Text URI where+	access f (URI txt) = (\txt' -> URI txt') <$> f txt++instance Identifiable URI where+	type Identificator URI = Text+	ident (URI txt) = txt++instance FromJSON URI where+	parseJSON = withText "URI" (pure . URI)++instance ToJSON URI where+	toJSON (URI txt) = String txt
− Network/API/Telegram/Bot/Object/Update/Message/Content/File/URI.hs
@@ -1,18 +0,0 @@-module Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI (URI (..)) where--import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (String), withObject, (.:))-import "base" Data.Eq (Eq)-import "base" Data.Functor ((<$>))-import "base" Data.Function (($))-import "base" Text.Show (Show)-import "text" Data.Text (Text)--newtype URI = URI Text-	deriving (Eq, Show)--instance FromJSON URI where-	parseJSON = withObject "URI" $ \v ->-		URI <$> v .: "file_id"--instance ToJSON URI where-	toJSON (URI txt) = String txt
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Video.hs view
@@ -9,9 +9,19 @@ import "base" Text.Show (Show) import "text" Data.Text (Text) -data Video = Video Int Int Int (Maybe Text) (Maybe Int)-	deriving Show+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Duration (Duration)+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.MIME (MIME)+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.URI (URI)+import Network.API.Telegram.Bot.Property (Identifiable (Identificator, ident)) +data Video = Video URI Duration Int Int (Maybe MIME) (Maybe Int) deriving Show++instance Identifiable Video where+	type Identificator Video = URI+	ident (Video uri _ _ _ _ _) = uri+ instance FromJSON Video where-	parseJSON = withObject "Video" $ \v -> Video <$> v .: "width" <*> v .: "height"-		<*> v .: "duration" <*> v .:? "mime_type" <*> v .:? "file_size"+	parseJSON = withObject "Video" $ \v -> Video+		<$> v .: "file_id" <*> v .: "duration"+		<*> v .: "width" <*> v .: "height"+		<*> v .:? "mime_type" <*> v .:? "file_size"
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Voice.hs view
@@ -7,10 +7,18 @@ import "base" Data.Function (($)) import "base" Data.Functor ((<$>)) import "base" Text.Show (Show)-import "text" Data.Text (Text) -data Voice = Voice Int (Maybe Text) (Maybe Int) deriving Show+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Duration (Duration)+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.MIME (MIME)+import Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.URI (URI)+import Network.API.Telegram.Bot.Property (Identifiable (Identificator, ident)) +data Voice = Voice URI Duration (Maybe MIME) (Maybe Int) deriving Show++instance Identifiable Voice where+	type Identificator Voice = URI+	ident (Voice uri _ _ _) = uri+ instance FromJSON Voice where-	parseJSON = withObject "Voice" $ \v -> Voice <$>-		v .: "duration" <*> v .:? "mime_type" <*> v .:? "file_size"+	parseJSON = withObject "Voice" $ \v -> Voice <$> v .: "file_id"+		<*> v .: "duration" <*> v .:? "mime_type" <*> v .:? "file_size"
Network/API/Telegram/Bot/Object/Update/Message/Content/Info/Contact.hs view
@@ -4,12 +4,21 @@ import "base" Control.Applicative ((<*>)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))+import "base" Data.Int (Int) import "base" Data.Maybe (Maybe) import "base" Text.Show (Show) import "text" Data.Text (Text) -data Contact = Contact Text (Maybe Text) (Maybe Text) Text (Maybe Text)-	deriving Show+import Network.API.Telegram.Bot.Object.Name (Name, First, Last)+import Network.API.Telegram.Bot.Property.Accessible (Accessible (access))++data Contact = Contact (First Name) (Maybe (Last Name)) (Maybe Int) Text (Maybe Text) deriving Show++instance Accessible (First Name) Contact where+	access f (Contact fn ln uid pn vc) = (\fn' -> Contact fn' ln uid pn vc) <$> f fn++instance Accessible (Maybe (Last Name)) Contact where+	access f (Contact fn ln uid pn vc) = (\ln' -> Contact fn ln' uid pn vc) <$> f ln  instance FromJSON Contact where 	parseJSON = withObject "Contact" $ \i -> Contact
telega.cabal view
@@ -1,5 +1,5 @@ name:                telega-version:             0.2.6+version:             0.2.7 synopsis:            Telegram Bot API binding description:         High-level bindings, typed entities, inline mode only homepage:            https://github.com/iokasimov/telega@@ -22,9 +22,11 @@     Network.API.Telegram.Bot     Network.API.Telegram.Bot.Core     Network.API.Telegram.Bot.Object+    Network.API.Telegram.Bot.Object.Language     Network.API.Telegram.Bot.Object.Member     Network.API.Telegram.Bot.Object.Member.Powers     Network.API.Telegram.Bot.Object.Member.Restrictions+    Network.API.Telegram.Bot.Object.Name     Network.API.Telegram.Bot.Object.Sender     Network.API.Telegram.Bot.Object.Update     Network.API.Telegram.Bot.Object.Update.Callback@@ -32,12 +34,13 @@     Network.API.Telegram.Bot.Object.Update.Message     Network.API.Telegram.Bot.Object.Update.Message.Content     Network.API.Telegram.Bot.Object.Update.Message.Content.File+    Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Caption+    Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.Duration+    Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.MIME+    Network.API.Telegram.Bot.Object.Update.Message.Content.File.Special.URI     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Audio-    Network.API.Telegram.Bot.Object.Update.Message.Content.File.Caption     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Document     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Photo-    Network.API.Telegram.Bot.Object.Update.Message.Content.File.Size-    Network.API.Telegram.Bot.Object.Update.Message.Content.File.URI     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Video     Network.API.Telegram.Bot.Object.Update.Message.Content.File.Voice     Network.API.Telegram.Bot.Object.Update.Message.Content.Info@@ -58,7 +61,7 @@     Network.API.Telegram.Bot.Utils   build-depends: base == 4.*, data-default, transformers, with, lens, aeson, text, unordered-containers, http-client, wreq   default-extensions: DataKinds, LambdaCase, OverloadedStrings, NoImplicitPrelude, PackageImports, GADTs,-    FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, UndecidableInstances+    FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, UndecidableInstances, StandaloneDeriving     TypeApplications, TypeFamilies, TypeFamilyDependencies, TypeOperators, ScopedTypeVariables   default-language: Haskell2010   ghc-options: -Wall -fno-warn-tabs