packages feed

telega 0.2.9 → 0.3.0

raw patch · 43 files changed

+96/−157 lines, 43 filesdep +jointdep −transformersdep −withsetup-changed

Dependencies added: joint

Dependencies removed: transformers, with

Files

CHANGELOG.md view
@@ -163,3 +163,10 @@ * Define `Persistable` instances for leaving `Group`, `Supergroup` or `Channel` chats * Change type of `Persistable`'s `endpoint` method to `Text` * Replace `wreq` on `req` as HTTP library++# 0.3.0+* Remove all `Show` deriving instances (library users can use standalone deriving)+* Rename `ask'` to `environment` for access user defined read-only environment+* Remove `with` package from `extra-deps`, put open product to `Utils` module+* Replace raw `Int` and `Int 64` on `ID Sender` and `ID Chat` in `Kick`, `Unban`, `Restrict` and `Promote` methods+* Use `joint` instead of `transformers`
Network/API/Telegram/Bot/Core.hs view
@@ -1,7 +1,7 @@-module Network.API.Telegram.Bot.Core (Telegram, telegram, ask', Token (..), Ok, result) where+module Network.API.Telegram.Bot.Core (Telegram, telegram, environment, Token (..), Ok, result) where  import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:))-import "base" Control.Applicative (Applicative ((<*>)))+import "base" Control.Applicative ((<*>)) import "base" Control.Exception (SomeException) import "base" Data.Bool (Bool (True, False)) import "base" Data.Eq (Eq)@@ -11,22 +11,20 @@ import "base" Data.Maybe (Maybe (Just, Nothing)) import "base" Data.Tuple (fst) import "base" System.IO (IO)-import "base" Text.Show (Show)+import "joint" Control.Joint (Reader, run, lift, get, (:>)) import "text" Data.Text (Text)-import "transformers" Control.Monad.Trans.Reader (ReaderT (runReaderT), ask)-import "transformers" Control.Monad.Trans.Except (ExceptT, runExceptT)  newtype Token = Token Text deriving Eq -type Telegram e a = ReaderT (e, Token) (ExceptT SomeException IO) a+type Telegram e = Reader (e, Token) :> Either SomeException :> IO  telegram :: Token -> e -> Telegram e a -> IO (Either SomeException a)-telegram token env = runExceptT . flip runReaderT (env, token)+telegram token env = run . flip run (env, token) -ask' :: Telegram e e-ask' = fst <$> ask+environment :: forall e . Telegram e e+environment = fst <$> lift @(Reader (e, Token)) get -data Ok a = Ok Bool a deriving Show+data Ok a = Ok Bool a  result :: Ok a -> Maybe a result (Ok True x) = Just x
Network/API/Telegram/Bot/Field/Caption.hs view
@@ -4,12 +4,11 @@ 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+newtype Caption = Caption Text  instance Accessible Text Caption where 	access f (Caption txt) = (\txt' -> Caption txt') <$> f txt
Network/API/Telegram/Bot/Field/Duration.hs view
@@ -3,11 +3,10 @@ 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+newtype Duration = Duration Int  instance Accessible Int Duration where 	access f (Duration int) = (\int' -> Duration int') <$> f int
Network/API/Telegram/Bot/Field/Filesize.hs view
@@ -3,11 +3,10 @@ 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 Filesize = Filesize Int deriving Show+newtype Filesize = Filesize Int  instance Accessible Int Filesize where 	access f (Filesize int) = (\int' -> Filesize int') <$> f int
Network/API/Telegram/Bot/Field/Height.hs view
@@ -3,11 +3,10 @@ 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 Height = Height Int deriving Show+newtype Height = Height Int  instance Accessible Int Height where 	access f (Height int) = (\int' -> Height int') <$> f int
Network/API/Telegram/Bot/Field/Language.hs view
@@ -5,12 +5,11 @@ 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+newtype Language = Language Text  instance Accessible Text Language where 	access f (Language txt) = (\txt' -> Language txt') <$> f txt
Network/API/Telegram/Bot/Field/MIME.hs view
@@ -4,12 +4,11 @@ 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+newtype MIME = MIME Text  instance Accessible Text MIME where 	access f (MIME txt) = (\txt' -> MIME txt') <$> f txt
Network/API/Telegram/Bot/Field/Name.hs view
@@ -5,12 +5,11 @@ 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+newtype Name = Name Text  instance Accessible Text Name where 	access f (Name txt) = (\txt' -> Name txt') <$> f txt@@ -23,8 +22,6 @@  data First a where First :: Name -> First Name -deriving instance Show a => Show (First a)- instance Accessible Text (First Name) where 	access f (First (Name txt)) = (\txt' -> First $ Name txt') <$> f txt @@ -36,8 +33,6 @@  data Last a where Last :: Name -> Last Name -deriving instance Show a => Show (Last a)- instance Accessible Text (Last Name) where 	access f (Last (Name txt)) = (\txt' -> Last $ Name txt') <$> f txt @@ -48,8 +43,6 @@ 	toJSON (Last name) = toJSON name  data Nick a where Nick :: Name -> Nick Name--deriving instance Show a => Show (Nick a)  instance Accessible Text (Nick Name) where 	access f (Nick (Name txt)) = (\txt' -> Nick $ Name txt') <$> f txt
Network/API/Telegram/Bot/Field/Title.hs view
@@ -2,12 +2,11 @@  import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show) import "text" Data.Text (Text)  import Network.API.Telegram.Bot.Property.Accessible (Accessible (access)) -newtype Title = Title Text deriving Show+newtype Title = Title Text  instance Accessible Text Title where 	access f (Title txt) = (\txt' -> Title txt') <$> f txt
Network/API/Telegram/Bot/Field/URI.hs view
@@ -5,13 +5,12 @@ 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)+newtype URI = URI Text deriving Eq  instance Accessible Text URI where 	access f (URI txt) = (\txt' -> URI txt') <$> f txt
Network/API/Telegram/Bot/Field/Width.hs view
@@ -3,11 +3,10 @@ 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 Width = Width Int deriving Show+newtype Width = Width Int  instance Accessible Int Width where 	access f (Width int) = (\int' -> Width int') <$> f int
Network/API/Telegram/Bot/Object/Chat.hs view
@@ -7,7 +7,6 @@ import "base" Data.Eq (Eq) import "base" Data.Functor ((<$>)) import "base" Data.Int (Int64)-import "base" Text.Show (Show)  import Network.API.Telegram.Bot.Property 	(Persistable (Payload, Returning, payload, endpoint), ID)@@ -32,7 +31,6 @@ data instance ID Chat = CHAT Int64  deriving instance Eq (ID Chat)-deriving instance Show (ID Chat)  instance FromJSON (ID Chat) where 	parseJSON o = CHAT <$> parseJSON o
Network/API/Telegram/Bot/Object/Chat/Channel.hs view
@@ -1,17 +1,12 @@ module Network.API.Telegram.Bot.Object.Chat.Channel (Channel (..)) where  import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:))-import "base" Control.Applicative ((<*>))-import "base" Control.Monad ((>>=), fail) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Data.Int (Int64)-import "base" Text.Show (Show)-import "text" Data.Text (Text)  import Network.API.Telegram.Bot.Field (Title) -data Channel = Channel Title deriving Show+data Channel = Channel Title  instance FromJSON Channel where 	parseJSON = withObject "Channel" $
Network/API/Telegram/Bot/Object/Chat/Group.hs view
@@ -5,18 +5,12 @@ import "base" Control.Monad ((>>=), fail) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Data.Int (Int64) import "base" Data.Maybe (Maybe)-import "base" Text.Show (Show) import "text" Data.Text (Text)  import Network.API.Telegram.Bot.Field (Title)-import Network.API.Telegram.Bot.Property.Identifiable (Identifiable (Identificator, ident)) -data Group-	= Basic Title-	| Super Title (Maybe Text)-	deriving Show+data Group = Basic Title | Super Title (Maybe Text)  instance FromJSON Group where 	parseJSON = withObject "Group" $ \chat -> chat .: "type" >>= \case
Network/API/Telegram/Bot/Object/Member.hs view
@@ -11,15 +11,15 @@ import "base" Data.Bool (Bool (True, False)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Data.Int (Int, Int64)+import "base" Data.Int (Int) import "base" Data.Semigroup ((<>))-import "base" Text.Show (Show) import "data-default" Data.Default (Default (def)) import "text" Data.Text (Text) +import Network.API.Telegram.Bot.Object.Chat (Chat) 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.Identifiable (Identifiable (Identificator, ident), ID) import Network.API.Telegram.Bot.Property.Persistable (Persistable (Payload, Returning, payload, endpoint)) import Network.API.Telegram.Bot.Utils (field) @@ -30,7 +30,6 @@ 	| Restricted Sender Restrictions Int 	| Left Sender 	| Kicked Sender Int-	deriving Show  instance Accessible Sender Member where 	access f (Creator sender) = (\sender' -> Creator sender') <$> f sender@@ -79,7 +78,7 @@ data Until = Forever | Until Int  data Kick a where-	Kick :: Int64 -> Int -> Until -> Kick Member+	Kick :: ID Chat -> ID Sender -> Until -> Kick Member  instance Persistable (Kick Member) where 	type Payload (Kick Member) = Kick Member@@ -91,7 +90,7 @@ 	endpoint _ = "kickChatMember"  data Unban a where-	Unban :: Int64 -> Int -> Unban Member+	Unban :: ID Chat -> ID Sender -> Unban Member  instance Persistable (Unban Member) where 	type Payload (Unban Member) = Unban Member@@ -102,7 +101,7 @@ 	endpoint _ = "unbanChatMember"  data Restrict a where-	Restrict :: Int64 -> Int -> Until -> Restrictions -> Restrict Member+	Restrict :: ID Chat -> ID Sender -> Until -> Restrictions -> Restrict Member  instance Persistable (Restrict Member) where 	type Payload (Restrict Member) = Restrict Member@@ -118,7 +117,7 @@ 	endpoint _ = "restrictChatMember"  data Promote a where-	Promote :: Int64 -> Int -> Until -> Powers -> Promote Member+	Promote :: ID Chat -> ID Sender -> Until -> Powers -> Promote Member  instance Persistable (Promote Member) where 	type Payload (Promote Member) = Promote Member
Network/API/Telegram/Bot/Object/Member/Powers.hs view
@@ -5,9 +5,8 @@ import "base" Control.Applicative ((<*>)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show) -data Powers = Powers Bool Bool Bool Bool Bool Bool Bool Bool deriving Show+data Powers = Powers Bool Bool Bool Bool Bool Bool Bool Bool  instance FromJSON Powers where 	parseJSON = withObject "Powers" $ \v -> Powers
Network/API/Telegram/Bot/Object/Member/Restrictions.hs view
@@ -5,9 +5,8 @@ import "base" Control.Applicative ((<*>)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show) -data Restrictions = Restrictions Bool Bool Bool Bool deriving Show+data Restrictions = Restrictions Bool Bool Bool Bool  instance FromJSON Restrictions where 	parseJSON = withObject "Restrictions" $ \v -> Restrictions
Network/API/Telegram/Bot/Object/Sender.hs view
@@ -3,15 +3,14 @@ import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON) 	, Object, withObject, (.:), (.:?)) import "aeson" Data.Aeson.Types (Parser)-import "base" Control.Applicative (Applicative ((<*>)))-import "base" Control.Monad (Monad ((>>=)))+import "base" Control.Applicative ((<*>))+import "base" Control.Monad ((>>=)) import "base" Data.Bool (Bool (False), bool) 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 Network.API.Telegram.Bot.Field (Language, Name, First, Last, Nick) import Network.API.Telegram.Bot.Property (Accessible (access), Identifiable (Identificator, ident), ID)@@ -19,7 +18,6 @@ data Sender 	= Bot (ID Sender) (Maybe (Nick Name)) (First Name) (Maybe (Last Name)) (Maybe Language) 	| Human (ID Sender) (Maybe (Nick Name)) (First Name) (Maybe (Last Name)) (Maybe Language)-	deriving Show  instance Eq Sender where 	Bot i _ _ _ _ == Bot i' _ _ _ _ = i == i'@@ -62,7 +60,6 @@ data instance ID Sender = SNDR Int  deriving instance Eq (ID Sender)-deriving instance Show (ID Sender)  instance FromJSON (ID Sender) where parseJSON o = SNDR <$> parseJSON o instance ToJSON (ID Sender) where toJSON (SNDR i) = toJSON i
Network/API/Telegram/Bot/Object/Update.hs view
@@ -10,7 +10,6 @@ import "base" Data.Function (($)) import "base" Data.Functor ((<$>)) import "base" Data.Int (Int)-import "base" Text.Show (Show)  import Network.API.Telegram.Bot.Object.Chat (Chat, ID) import Network.API.Telegram.Bot.Property (Accessible (access), Identifiable (Identificator, ident))@@ -19,7 +18,6 @@ 	= Query (ID Update) Callback 	| Membership (ID Update) Moving 	| Incoming (ID Update) Message-	deriving Show  instance Accessible (ID Chat) Update where 	access f (Query i callback) = Query i <$> access f callback@@ -41,7 +39,6 @@ data instance ID Update = UPD Int  deriving instance Eq (ID Update)-deriving instance Show (ID Update)  instance FromJSON (ID Update) where parseJSON o = UPD <$> parseJSON o instance ToJSON (ID Update) where toJSON (UPD i) = toJSON i
Network/API/Telegram/Bot/Object/Update/Callback.hs view
@@ -4,12 +4,11 @@ import Network.API.Telegram.Bot.Object.Update.Callback.Notification as Exports  import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), withObject, (.:))-import "base" Control.Applicative (Applicative ((<*>)))+import "base" Control.Applicative ((<*>)) import "base" Data.Eq (Eq ((==))) import "base" Data.Function (flip, ($)) import "base" Data.Functor ((<$>)) import "base" Data.Semigroup ((<>))-import "base" Text.Show (Show) import "text" Data.Text (Text)  import Network.API.Telegram.Bot.Object.Chat (Chat)@@ -19,7 +18,7 @@ import Network.API.Telegram.Bot.Property.Persistable (Persistable (Payload, Returning, payload, endpoint)) import Network.API.Telegram.Bot.Utils (field) -data Callback = Datatext (ID Callback) Sender Message Text deriving Show+data Callback = Datatext (ID Callback) Sender Message Text  instance Eq Callback where 	c == c' = ident c == ident c'@@ -56,7 +55,6 @@ data instance ID Callback = CB Text  deriving instance Eq (ID Callback)-deriving instance Show (ID Callback)  instance FromJSON (ID Callback) where parseJSON o = CB <$> parseJSON o instance ToJSON (ID Callback) where toJSON (CB i) = toJSON i
Network/API/Telegram/Bot/Object/Update/Message.hs view
@@ -9,29 +9,26 @@ import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (Object), withObject, (.:)) import "aeson" Data.Aeson.Types (Object, Parser) import "base" Control.Applicative ((<*>), (<|>))-import "base" Control.Monad (Monad ((>>=)), fail)+import "base" Control.Monad (fail, (>>=)) import "base" Data.Bool (Bool (True)) import "base" Data.Eq (Eq ((==))) import "base" Data.Function (flip, ($)) import "base" Data.Functor ((<$>)) import "base" Data.Int (Int) import "base" Data.Semigroup ((<>))-import "base" Text.Show (Show) import "text" Data.Text (Text)-import "with" Data.With (type (:&:)((:&:)))  import Network.API.Telegram.Bot.Field (Caption, URI) import Network.API.Telegram.Bot.Object.Chat (Chat, Group, Channel, ID) 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)+import Network.API.Telegram.Bot.Utils (type (:*:)((:*:)), field)  data Message 	= Direct (ID Message) Origin Content 	| Forwarded (ID Message) Origin Content 	| Replied (ID Message) Origin Content Message-	deriving Show  instance Eq Message where 	m == m' = ident m == ident m'@@ -105,10 +102,10 @@ 	payload (Send chat_id text) = field "chat_id" chat_id <> field "text" text 	endpoint _ = "sendMessage" -instance Persistable (Send (Text :&: Keyboard)) where-	type Payload (Send (Text :&: Keyboard)) = Send (Text :&: Keyboard)-	type Returning (Send (Text :&: Keyboard)) = Message-	payload (Send chat_id (text :&: reply_markup)) = field "chat_id" chat_id+instance Persistable (Send (Text :*: Keyboard)) where+	type Payload (Send (Text :*: Keyboard)) = Send (Text :*: Keyboard)+	type Returning (Send (Text :*: Keyboard)) = Message+	payload (Send chat_id (text :*: reply_markup)) = field "chat_id" chat_id 		<> field "text" text <> field "reply_markup" reply_markup 	endpoint _ = "sendMessage" @@ -120,10 +117,10 @@ 		<> 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 :&: Audio)-	type Returning (Send (Caption :&: Audio)) = Message-	payload (Send chat_id (caption :&: audio)) = payload (Send chat_id audio) <> field "caption" caption+instance Persistable (Send (Caption :*: Audio)) where+	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@@ -134,10 +131,10 @@ 		<> 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 :&: Document)-	type Returning (Send (Caption :&: Document)) = Message-	payload (Send chat_id (caption :&: document)) = payload (Send chat_id document) <> field "caption" caption+instance Persistable (Send (Caption :*: Document)) where+	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@@ -148,10 +145,10 @@ 		<> 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 :&: Video)-	type Returning (Send (Caption :&: Video)) = Message-	payload (Send chat_id (caption :&: video)) = payload (Send chat_id video) <> field "caption" caption+instance Persistable (Send (Caption :*: Video)) where+	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@@ -162,10 +159,10 @@ 		<> 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 :&: Voice)-	type Returning (Send (Caption :&: Voice)) = Message-	payload (Send chat_id (caption :&: voice)) = payload (Send chat_id voice) <> field "caption" caption+instance Persistable (Send (Caption :*: Voice)) where+	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"  instance Persistable (Send Photo) where@@ -174,10 +171,10 @@ 	payload (Send chat_id uri) = field "chat_id" chat_id <> field "photo" uri 	endpoint _ = "sendPhoto" -instance Persistable (Send (Caption :&: Photo)) where-	type Payload (Send (Caption :&: Photo)) = Send (Caption :&: URI)-	type Returning (Send (Caption :&: Photo)) = Message-	payload (Send chat_id (caption :&: uri)) = field "chat_id" chat_id+instance Persistable (Send (Caption :*: Photo)) where+	type Payload (Send (Caption :*: Photo)) = Send (Caption :*: URI)+	type Returning (Send (Caption :*: Photo)) = Message+	payload (Send chat_id (caption :*: uri)) = field "chat_id" chat_id 		<> field "photo" uri <> field "caption" caption 	endpoint _ = "sendPhoto" @@ -328,7 +325,6 @@ data instance ID Message = MSG Int  deriving instance Eq (ID Message)-deriving instance Show (ID Message)  instance FromJSON (ID Message) where parseJSON o = MSG <$> parseJSON o instance ToJSON (ID Message) where toJSON (MSG i) = toJSON i
Network/API/Telegram/Bot/Object/Update/Message/Content.hs view
@@ -7,22 +7,20 @@  import "aeson" Data.Aeson (FromJSON (parseJSON), withArray, withObject, (.:), (.:?)) import "aeson" Data.Aeson.Types (Object, Parser, Value (Object))-import "base" Control.Applicative (Applicative ((<*>)), Alternative (empty, (<|>)))-import "base" Control.Monad (Monad ((>>=)), fail)+import "base" Control.Applicative (empty, (<*>), (<|>))+import "base" Control.Monad (fail, (>>=)) import "base" Data.Bool (bool) import "base" Data.Function ((.), ($)) import "base" Data.Functor ((<$>)) import "base" Data.Foldable (Foldable (foldr)) import "base" Data.Int (Int) import "base" Data.Maybe (Maybe)-import "base" Text.Show (Show) import "base" Prelude ((+)) import "text" Data.Text (Text, drop, take)  import Network.API.Telegram.Bot.Field (Caption)  data Status = Opened | Closed-	deriving Show  data Content 	= Textual Text@@ -30,7 +28,6 @@ 	| Attachment (Maybe Caption) File 	| Polling Text Status Poll 	| Information Info-	deriving Show  instance FromJSON Content where 	parseJSON = withObject "Content" $ \v -> command v <|> attachment v <|> information v <|> polling v <|> textual v where
Network/API/Telegram/Bot/Object/Update/Message/Content/File.hs view
@@ -10,7 +10,6 @@ import "base" Control.Applicative ((<|>)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show)  data File 	= Audiofile Audio@@ -18,7 +17,6 @@ 	| General Document 	| Voicerecord Voice 	| Photography [Photosize]-	deriving Show  instance FromJSON File where 	parseJSON = withObject "Message" $ \v ->
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Audio.hs view
@@ -5,13 +5,12 @@ import "base" Data.Maybe (Maybe) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show) import "text" Data.Text (Text)  import Network.API.Telegram.Bot.Field (Duration, Filesize, MIME, Title, URI) import Network.API.Telegram.Bot.Property (Accessible (access), Identifiable (Identificator, ident)) -data Audio = Audio URI Duration (Maybe Text) (Maybe Title) (Maybe MIME) (Maybe Filesize) deriving Show+data Audio = Audio URI Duration (Maybe Text) (Maybe Title) (Maybe MIME) (Maybe Filesize)  instance Accessible Duration Audio where 	access f (Audio uri duration performer title mime fs) =
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Document.hs view
@@ -5,12 +5,11 @@ import "base" Data.Maybe (Maybe) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show)  import Network.API.Telegram.Bot.Field (Filesize, MIME, Title, URI) import Network.API.Telegram.Bot.Property (Identifiable (Identificator, ident)) -data Document = Document URI (Maybe Title) (Maybe MIME) (Maybe Filesize) deriving Show+data Document = Document URI (Maybe Title) (Maybe MIME) (Maybe Filesize)  instance Identifiable Document where 	type Identificator Document = URI
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Photo.hs view
@@ -6,14 +6,13 @@ import "base" Data.Function (($)) import "base" Data.Functor ((<$>)) import "base" Data.Maybe (Maybe)-import "base" Text.Show (Show)  import Network.API.Telegram.Bot.Field (Height, Width, Filesize, URI) import Network.API.Telegram.Bot.Property (Accessible (access), Identifiable (Identificator, ident))  data Photo -data Photosize = Photosize URI Height Width (Maybe Filesize) deriving Show+data Photosize = Photosize URI Height Width (Maybe Filesize)  instance Eq Photosize where 	s == s' = ident s == ident s'
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Video.hs view
@@ -5,12 +5,11 @@ import "base" Data.Maybe (Maybe) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show)  import Network.API.Telegram.Bot.Field (Duration, Filesize, MIME, Height, Width, URI) import Network.API.Telegram.Bot.Property (Accessible (access), Identifiable (Identificator, ident)) -data Video = Video URI Duration Height Width (Maybe MIME) (Maybe Filesize) deriving Show+data Video = Video URI Duration Height Width (Maybe MIME) (Maybe Filesize)  instance Accessible Duration Video where 	access f (Video uri duration height width mime fs) =
Network/API/Telegram/Bot/Object/Update/Message/Content/File/Voice.hs view
@@ -5,12 +5,11 @@ import "base" Data.Maybe (Maybe) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show)  import Network.API.Telegram.Bot.Field (Duration, Filesize, MIME, URI) import Network.API.Telegram.Bot.Property (Accessible (access), Identifiable (Identificator, ident)) -data Voice = Voice URI Duration (Maybe MIME) (Maybe Filesize) deriving Show+data Voice = Voice URI Duration (Maybe MIME) (Maybe Filesize)  instance Accessible Duration Voice where 	access f (Voice uri duration mime fs) =
Network/API/Telegram/Bot/Object/Update/Message/Content/Info.hs view
@@ -8,13 +8,11 @@ import "base" Control.Applicative ((<|>)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show)  data Info 	= Point Location 	| User Contact 	| Meeting Venue-	deriving Show  instance FromJSON Info where 	parseJSON = withObject "Info" $ \v ->
Network/API/Telegram/Bot/Object/Update/Message/Content/Info/Contact.hs view
@@ -6,13 +6,12 @@ import "base" Data.Functor ((<$>)) import "base" Data.Int (Int) import "base" Data.Maybe (Maybe)-import "base" Text.Show (Show) import "text" Data.Text (Text)  import Network.API.Telegram.Bot.Field (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+data Contact = Contact (First Name) (Maybe (Last Name)) (Maybe Int) Text (Maybe Text)  instance Accessible (First Name) Contact where 	access f (Contact fn ln uid pn vc) = (\fn' -> Contact fn' ln uid pn vc) <$> f fn
Network/API/Telegram/Bot/Object/Update/Message/Content/Info/Location.hs view
@@ -6,10 +6,8 @@ import "base" Data.Functor ((<$>)) import "base" Data.Int (Int) 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
Network/API/Telegram/Bot/Object/Update/Message/Content/Info/Venue.hs view
@@ -5,13 +5,12 @@ 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.Field (Title) import Network.API.Telegram.Bot.Object.Update.Message.Content.Info.Location (Location) -data Venue = Venue Title Text Location (Maybe Text) (Maybe Text) deriving Show+data Venue = Venue Title Text Location (Maybe Text) (Maybe Text)  instance FromJSON Venue where 	parseJSON = withObject "Venue" $ \i -> Venue
Network/API/Telegram/Bot/Object/Update/Message/Content/Poll.hs view
@@ -6,11 +6,9 @@ import "base" Control.Applicative ((<*>)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show) import "text" Data.Text (Text)  data Poll = Poll Text [Option]-	deriving Show  instance FromJSON Poll where 	parseJSON = withObject "Pool" $ \v ->
Network/API/Telegram/Bot/Object/Update/Message/Content/Poll/Option.hs view
@@ -5,11 +5,10 @@ import "base" Data.Function (($)) import "base" Data.Functor ((<$>)) import "base" Data.Int (Int)-import "base" Text.Show (Show)  import Network.API.Telegram.Bot.Field (Title) -data Option = Option Title Int deriving Show+data Option = Option Title Int  instance FromJSON Option where 	parseJSON = withObject "Option" $ \v -> Option
Network/API/Telegram/Bot/Object/Update/Message/Keyboard.hs view
@@ -5,9 +5,8 @@ import "aeson" Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), object, withObject, (.:), (.=)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show) -data Keyboard = Inline [[Button]] deriving Show+data Keyboard = Inline [[Button]]  instance FromJSON Keyboard where 	parseJSON = withObject "Inline" $ \v ->
Network/API/Telegram/Bot/Object/Update/Message/Keyboard/Button.hs view
@@ -4,14 +4,13 @@ 	, Object, Value (Object), object, withObject, (.:), (.:?), (.=)) import "aeson" Data.Aeson.Types (Parser) import "base" Control.Applicative (Applicative (pure, (<*>)), Alternative ((<|>)))-import "base" Control.Monad (Monad ((>>=)), fail)+import "base" Control.Monad (fail, (>>=)) import "base" Data.Function ((.), ($)) import "base" Data.Functor (Functor (fmap), (<$>)) import "base" Data.Maybe (Maybe, maybe)-import "base" Text.Show (Show) import "text" Data.Text (Text) -data Button = Button Text Pressed deriving Show+data Button = Button Text Pressed  instance FromJSON Button where 	parseJSON = withObject "Button" $ \v ->@@ -23,7 +22,7 @@ 	toJSON (Button text (Callback cbd)) = object 		["text" .= text, "callback_data" .= cbd] -data Pressed = Open Text | Callback Text deriving Show+data Pressed = Open Text | Callback Text  instance FromJSON Pressed where 	parseJSON = withObject "Pressed" $ \v ->
Network/API/Telegram/Bot/Object/Update/Message/Origin.hs view
@@ -3,10 +3,9 @@ import "aeson" Data.Aeson (FromJSON (parseJSON), withObject, (.:)) import "aeson" Data.Aeson.Types (Object, Parser, Value (Object)) import "base" Control.Applicative ((<*>))-import "base" Control.Monad (Monad ((>>=)))+import "base" Control.Monad ((>>=)) import "base" Data.Function (($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show) import "text" Data.Text (Text)  import Network.API.Telegram.Bot.Object.Chat (Chat, ID,Channel, Group)@@ -17,7 +16,6 @@ 	= Private (ID Chat) Sender 	| Group (ID Chat) Group Sender 	| Blog (ID Chat) Channel-	deriving Show  instance Accessible (ID Chat) Origin where 	access f (Private i sender) = (\i' -> Private i' sender) <$> f i
Network/API/Telegram/Bot/Object/Update/Moving.hs view
@@ -6,7 +6,6 @@ import "base" Control.Monad ((>>=)) import "base" Data.Function (flip, ($)) import "base" Data.Functor ((<$>))-import "base" Text.Show (Show)  import Network.API.Telegram.Bot.Object.Chat (Chat, ID) import Network.API.Telegram.Bot.Object.Chat.Group (Group)@@ -16,7 +15,6 @@ data Moving 	= Gone Sender (ID Chat) Group 	| Joined [Sender] (ID Chat) Group-	deriving Show  instance Accessible Group Moving where 	access f (Gone sender i group) = Gone sender i <$> f group
Network/API/Telegram/Bot/Property/Persistable.hs view
@@ -1,18 +1,17 @@ module Network.API.Telegram.Bot.Property.Persistable (Persistable (..)) where  import "aeson" Data.Aeson (FromJSON, Object, Value (Object))-import "base" Control.Exception (try)+import "base" Control.Exception (SomeException, try) import "base" Control.Monad ((>>=)) import "base" Data.Function ((.), ($)) import "base" Data.Functor ((<$>)) import "base" Data.Maybe (fromJust) import "base" Data.Monoid (mempty) import "base" Data.Tuple (snd)+import "base" System.IO (IO) import "data-default" Data.Default (def)+import "joint" Control.Joint (Reader, get, lift) import "text" Data.Text (Text)-import "transformers" Control.Monad.Trans.Class (lift)-import "transformers" Control.Monad.Trans.Except (ExceptT (ExceptT))-import "transformers" Control.Monad.Trans.Reader (ask) import "req" Network.HTTP.Req (POST (POST), ReqBodyJson (ReqBodyJson) 	, https, jsonResponse, req, responseBody, runReq, (/:)) @@ -32,7 +31,9 @@ 	persist_ x = request @() @_ (endpoint x) (Object $ payload x)  request :: forall a e . FromJSON a => Text -> Value -> Telegram e a-request e p = snd <$> ask >>= \(Token token) -> lift . ExceptT . try .-	(<$>) (fromJust . result . responseBody) . runReq def $-		req POST (https "api.telegram.org" /: token /: e)+request e p = snd <$> lift @(Reader (e, Token)) get >>= lift . try @SomeException . send >>= lift where++	send :: FromJSON a => Token -> IO a+	send (Token token) = (<$>) (fromJust . result . responseBody) . runReq def+		$ req POST (https "api.telegram.org" /: token /: e) 			(ReqBodyJson p) (jsonResponse @(Ok a)) mempty
Network/API/Telegram/Bot/Utils.hs view
@@ -1,9 +1,13 @@-module Network.API.Telegram.Bot.Utils (field) where+module Network.API.Telegram.Bot.Utils ((:*:)((:*:)), field) where  import "aeson" Data.Aeson (ToJSON (toJSON), Object) import "base" Data.Function ((.)) import "text" Data.Text (Text) import "unordered-containers" Data.HashMap.Strict (singleton)++infixr 1 :*:++data (:*:) a b = a :*: b  field :: ToJSON a => Text -> a -> Object field key = singleton key . toJSON
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
telega.cabal view
@@ -1,5 +1,5 @@ name:                telega-version:             0.2.9+version:             0.3.0 synopsis:            Telegram Bot API binding description:         High-level bindings, typed entities, inline mode only homepage:            https://github.com/iokasimov/telega@@ -66,7 +66,7 @@     Network.API.Telegram.Bot.Property.Identifiable     Network.API.Telegram.Bot.Property.Persistable     Network.API.Telegram.Bot.Utils-  build-depends: base == 4.*, data-default, transformers, with, lens, aeson, text, unordered-containers, http-client, req+  build-depends: base == 4.*, data-default, joint, lens, aeson, text, unordered-containers, http-client, req   default-extensions: DataKinds, LambdaCase, OverloadedStrings, NoImplicitPrelude, PackageImports, GADTs,     FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, UndecidableInstances, StandaloneDeriving     TypeApplications, TypeFamilies, TypeFamilyDependencies, TypeOperators, ScopedTypeVariables