Skip to content

Commit

Permalink
Merge pull request #195 from cblp/hlint
Browse files Browse the repository at this point in the history
  • Loading branch information
swamp-agr authored Nov 7, 2024
2 parents c297c16 + 2bd1a3e commit 027648c
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 71 deletions.
8 changes: 4 additions & 4 deletions telegram-bot-api/src/Telegram/Bot/API/Forum.hs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ editGeneralForumTopic = client (Proxy @EditGeneralForumTopic)

-- ** 'closeGeneralForumTopic'

data CloseGeneralForumTopicRequest = CloseGeneralForumTopicRequest
newtype CloseGeneralForumTopicRequest = CloseGeneralForumTopicRequest
{ closeGeneralForumTopicChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername).
}
deriving Generic
Expand All @@ -206,7 +206,7 @@ closeGeneralForumTopic = client (Proxy @CloseGeneralForumTopic)

-- ** 'reopenGeneralForumTopic'

data ReopenGeneralForumTopicRequest = ReopenGeneralForumTopicRequest
newtype ReopenGeneralForumTopicRequest = ReopenGeneralForumTopicRequest
{ reopenGeneralForumTopicRequestChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername).
}
deriving Generic
Expand All @@ -224,7 +224,7 @@ reopenGeneralForumTopic = client (Proxy @ReopenGeneralForumTopic)

-- ** 'hideGeneralForumTopic'

data HideGeneralForumTopicRequest = HideGeneralForumTopicRequest
newtype HideGeneralForumTopicRequest = HideGeneralForumTopicRequest
{ hideGeneralForumTopicChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername).
}
deriving Generic
Expand All @@ -242,7 +242,7 @@ hideGeneralForumTopic = client (Proxy @HideGeneralForumTopic)

-- ** 'unhideGeneralForumTopic'

data UnhideGeneralForumTopicRequest = UnhideGeneralForumTopicRequest
newtype UnhideGeneralForumTopicRequest = UnhideGeneralForumTopicRequest
{ unhideGeneralForumTopicChatId :: SomeChatId -- ^ Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
}
deriving Generic
Expand Down
2 changes: 1 addition & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Internal/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ constructType :: Name -> [Type] -> Q Type
constructType typeN tys = foldr arrAp baseTy (filter (not . isMaybeTy) tys)
where
baseTy = conT typeN
arrAp a b = appT (appT arrowT (pure a)) b
arrAp a = appT (appT arrowT (pure a))


-- Predicates over TH
Expand Down
3 changes: 1 addition & 2 deletions telegram-bot-api/src/Telegram/Bot/API/Internal/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE CPP #-}
module Telegram.Bot.API.Internal.Utils where

Expand Down Expand Up @@ -95,7 +94,7 @@ instance GSomeJSON f => GSomeJSON (D1 d f) where

instance (ToJSON a, FromJSON a) => GSomeJSON (C1 c (S1 s (K1 i a))) where
gsomeToJSON (M1 (M1 (K1 x))) = toJSON x
gsomeParseJSON js = (M1 . M1 . K1) <$> parseJSON js
gsomeParseJSON js = M1 . M1 . K1 <$> parseJSON js

instance (GSomeJSON f, GSomeJSON g) => GSomeJSON (f :+: g) where
gsomeToJSON (L1 x) = gsomeToJSON x
Expand Down
10 changes: 1 addition & 9 deletions telegram-bot-api/src/Telegram/Bot/API/Methods.hs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TemplateHaskell #-}
module Telegram.Bot.API.Methods
( module Telegram.Bot.API.Types.ParseMode
, module Telegram.Bot.API.Types.SomeReplyMarkup

, module Telegram.Bot.API.Methods.AnswerCallbackQuery
, module Telegram.Bot.API.Methods.ApproveChatJoinRequest
, module Telegram.Bot.API.Methods.BanChatMember
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Telegram.Bot.API.Internal.TH
-- ** 'getChatMenuButton'

-- | Request parameters for 'getChatMenuButton'.
data GetChatMenuButtonRequest = GetChatMenuButtonRequest
newtype GetChatMenuButtonRequest = GetChatMenuButtonRequest
{ getChatMenuButtonRequestChatId :: Maybe ChatId -- ^ Unique identifier for the target private chat. If not specified, default bot's menu button will be returned.
}
deriving Generic
Expand Down
26 changes: 13 additions & 13 deletions telegram-bot-api/src/Telegram/Bot/API/Methods/SendDocument.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,25 @@ pattern DocumentFile x y = MakeDocumentFile (InputFile x y)
instance ToMultipart Tmp SendDocumentRequest where
toMultipart SendDocumentRequest{..} = MultipartData fields files where
fields =
[ Input "document" $ T.pack $ "attach://file"
[ Input "document" "attach://file"
, Input "chat_id" $ case sendDocumentChatId of
SomeChatId (ChatId chat_id) -> T.pack $ show chat_id
SomeChatUsername txt -> txt
] <>
( (maybe id (\t -> ((Input "message_thread_id") (T.pack $ show t):)) sendDocumentMessageThreadId)
$ (maybe id (\_ -> ((Input "thumbnail" "attach://thumbnail"):)) sendDocumentThumbnail)
$ (maybe id (\t -> ((Input "caption" t):)) sendDocumentCaption)
$ (maybe id (\t -> ((Input "parse_mode" (TL.toStrict $ encodeToLazyText t)):)) sendDocumentParseMode)
$ (maybe id (\t -> ((Input "caption_entities" (TL.toStrict $ encodeToLazyText t)):)) sendDocumentCaptionEntities)
$ (maybe id (\t -> ((Input "disable_notification" (bool "false" "true" t)):)) sendDocumentDisableNotification)
$ (maybe id (\t -> ((Input "disable_content_type_detection" (bool "false" "true" t)):)) sendDocumentDisableContentTypeDetection)
$ (maybe id (\t -> ((Input "protect_content" (bool "false" "true" t)):)) sendDocumentProtectContent)
$ (maybe id (\t -> ((Input "reply_to_message_id" (TL.toStrict $ encodeToLazyText t)):)) sendDocumentReplyToMessageId)
$ (maybe id (\t -> ((Input "reply_parameters" (TL.toStrict $ encodeToLazyText t)):)) sendDocumentReplyParameters)
$ (maybe id (\t -> ((Input "reply_markup" (TL.toStrict $ encodeToLazyText t)):)) sendDocumentReplyMarkup)
maybe id (\t -> (Input "message_thread_id" (T.pack $ show t) :)) sendDocumentMessageThreadId
( maybe id (const (Input "thumbnail" "attach://thumbnail" :)) sendDocumentThumbnail
$ maybe id (\t -> (Input "caption" t :)) sendDocumentCaption
$ maybe id (\t -> (Input "parse_mode" (TL.toStrict $ encodeToLazyText t) :)) sendDocumentParseMode
$ maybe id (\t -> (Input "caption_entities" (TL.toStrict $ encodeToLazyText t) :)) sendDocumentCaptionEntities
$ maybe id (\t -> (Input "disable_notification" (bool "false" "true" t) :)) sendDocumentDisableNotification
$ maybe id (\t -> (Input "disable_content_type_detection" (bool "false" "true" t) :)) sendDocumentDisableContentTypeDetection
$ maybe id (\t -> (Input "protect_content" (bool "false" "true" t) :)) sendDocumentProtectContent
$ maybe id (\t -> (Input "reply_to_message_id" (TL.toStrict $ encodeToLazyText t) :)) sendDocumentReplyToMessageId
$ maybe id (\t -> (Input "reply_parameters" (TL.toStrict $ encodeToLazyText t) :)) sendDocumentReplyParameters
$ maybe id (\t -> (Input "reply_markup" (TL.toStrict $ encodeToLazyText t) :)) sendDocumentReplyMarkup
[])
files
= (FileData "file" (T.pack $ takeFileName path) ct path)
= FileData "file" (T.pack $ takeFileName path) ct path
: maybe [] (\t -> [FileData "thumbnail" (T.pack $ takeFileName t) "image/jpeg" t]) sendDocumentThumbnail

(path, ct) = case sendDocumentDocument of
Expand Down
26 changes: 13 additions & 13 deletions telegram-bot-api/src/Telegram/Bot/API/Methods/SendPhoto.hs
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,25 @@ data SendPhotoRequest = SendPhotoRequest
instance ToMultipart Tmp SendPhotoRequest where
toMultipart SendPhotoRequest{..} = MultipartData fields files where
fields =
[ Input "photo" $ T.pack $ "attach://file"
[ Input "photo" "attach://file"
, Input "chat_id" $ case sendPhotoChatId of
SomeChatId (ChatId chat_id) -> T.pack $ show chat_id
SomeChatUsername txt -> txt
] <>
( (maybe id (\t -> ((Input "message_thread_id" (T.pack $ show t)):)) sendPhotoMessageThreadId)
$ (maybe id (\_ -> ((Input "thumb" "attach://thumb"):)) sendPhotoThumb)
$ (maybe id (\t -> ((Input "caption" t):)) sendPhotoCaption)
$ (maybe id (\t -> ((Input "parse_mode" (TL.toStrict . TL.replace "\"" "" $ encodeToLazyText t)):)) sendPhotoParseMode)
$ (maybe id (\t -> ((Input "caption_entities" (TL.toStrict $ encodeToLazyText t)):)) sendPhotoCaptionEntities)
$ (maybe id (\t -> ((Input "has_spoiler" (bool "false" "true" t)):)) sendPhotoHasSpoiler)
$ (maybe id (\t -> ((Input "disable_notification" (bool "false" "true" t)):)) sendPhotoDisableNotification)
$ (maybe id (\t -> ((Input "protect_content" (bool "false" "true" t)):)) sendPhotoProtectContent)
$ (maybe id (\t -> ((Input "reply_to_message_id" (TL.toStrict $ encodeToLazyText t)):)) sendPhotoReplyToMessageId)
$ (maybe id (\t -> ((Input "reply_parameters" (TL.toStrict $ encodeToLazyText t)):)) sendPhotoReplyParameters)
$ (maybe id (\t -> ((Input "reply_markup" (TL.toStrict $ encodeToLazyText t)):)) sendPhotoReplyMarkup)
maybe id (\t -> (Input "message_thread_id" (T.pack $ show t) :)) sendPhotoMessageThreadId
( maybe id (const (Input "thumb" "attach://thumb" :)) sendPhotoThumb
$ maybe id (\t -> (Input "caption" t :)) sendPhotoCaption
$ maybe id (\t -> (Input "parse_mode" (TL.toStrict . TL.replace "\"" "" $ encodeToLazyText t) :)) sendPhotoParseMode
$ maybe id (\t -> (Input "caption_entities" (TL.toStrict $ encodeToLazyText t) :)) sendPhotoCaptionEntities
$ maybe id (\t -> (Input "has_spoiler" (bool "false" "true" t) :)) sendPhotoHasSpoiler
$ maybe id (\t -> (Input "disable_notification" (bool "false" "true" t) :)) sendPhotoDisableNotification
$ maybe id (\t -> (Input "protect_content" (bool "false" "true" t) :)) sendPhotoProtectContent
$ maybe id (\t -> (Input "reply_to_message_id" (TL.toStrict $ encodeToLazyText t) :)) sendPhotoReplyToMessageId
$ maybe id (\t -> (Input "reply_parameters" (TL.toStrict $ encodeToLazyText t) :)) sendPhotoReplyParameters
$ maybe id (\t -> (Input "reply_markup" (TL.toStrict $ encodeToLazyText t) :)) sendPhotoReplyMarkup
[])
files
= (FileData "file" (T.pack $ takeFileName path) ct path)
= FileData "file" (T.pack $ takeFileName path) ct path
: maybe [] (\t -> [FileData "thumb" (T.pack $ takeFileName t) "image/jpeg" t]) sendPhotoThumb

(path, ct) = case sendPhotoPhoto of
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
module Telegram.Bot.API.Methods.SetStickerSetTitle where
Expand All @@ -23,4 +22,4 @@ type SetStickerSetTitle = "setStickerSetTitle"
setStickerSetTitle :: Text -- ^ Sticker set name
-> Text -- ^ Sticker set title, 1-64 characters
-> ClientM (Response Bool)
setStickerSetTitle = client (Proxy @SetStickerSetTitle)
setStickerSetTitle = client (Proxy @SetStickerSetTitle)
1 change: 0 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Passport.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DataKinds #-}
module Telegram.Bot.API.Passport where

Expand Down
2 changes: 1 addition & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Stickers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ sendSticker r =
-- ** 'getCustomEmojiStickers'

-- | Request parameters for 'getCustomEmojiStickers'.
data GetCustomEmojiStickersRequest = GetCustomEmojiStickersRequest
newtype GetCustomEmojiStickersRequest = GetCustomEmojiStickersRequest
{ getCustomEmojiStickersRequestCustomEmojiIds :: [Text] -- ^ List of custom emoji identifiers. At most 200 custom emoji identifiers can be specified.
}
deriving Generic
Expand Down
11 changes: 2 additions & 9 deletions telegram-bot-api/src/Telegram/Bot/API/Types.hs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Telegram.Bot.API.Types
( RequiredQueryParam
( RequiredQueryParam
, module Telegram.Bot.API.Types.Animation
, module Telegram.Bot.API.Types.Audio
, module Telegram.Bot.API.Types.BotCommand
Expand Down Expand Up @@ -268,7 +261,7 @@ type RequiredQueryParam = QueryParam' '[Required , Strict]
-- * Games

-- | Your bot can offer users HTML5 games to play solo or to compete against each other in groups and one-on-one chats. Create games via @BotFather using the /newgame command. Please note that this kind of power requires responsibility: you will need to accept the terms for each game that your bots will be offering.
--
--
-- Games are a new type of content on Telegram, represented by the Game and InlineQueryResultGame objects.
-- Once you've created a game via BotFather, you can send games to chats as regular messages using the sendGame method, or use inline mode with InlineQueryResultGame.
-- If you send the game message without any buttons, it will automatically have a 'Play GameName' button. When this button is pressed, your bot gets a CallbackQuery with the game_short_name of the requested game. You provide the correct URL for this particular user and the app opens the game in the in-app browser.
Expand Down
1 change: 0 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Types/Birthdate.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Telegram.Bot.API.Types.Birthdate where

import Data.Aeson (FromJSON (..), ToJSON (..))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Telegram.Bot.API.Types.BotCommandScope where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Telegram.Bot.API.Internal.Utils
-- ** 'BotShortDescription'

-- | This object represents the bot's short description.
data BotShortDescription = BotShortDescription
newtype BotShortDescription = BotShortDescription
{ botShortDescriptionShortDescription :: Text -- ^ The bot's short description.
}
deriving (Generic, Show)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Telegram.Bot.API.Types.BackgroundType
-- ** 'ChatBackground'

-- | This object represents a chat background.
data ChatBackground = ChatBackground
newtype ChatBackground = ChatBackground
{ chatBackgroundType :: BackgroundType -- ^ Type of the background.
}
deriving (Generic, Show)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Telegram.Bot.API.Internal.Utils
-- ** 'ChatBoostAdded'

-- | This object represents a boost added to a chat or changed.
data ChatBoostAdded = ChatBoostAdded
newtype ChatBoostAdded = ChatBoostAdded
{ chatBoostAddedBoostCount :: Int -- ^ Number of boosts added by the user.
}
deriving (Generic, Show)
Expand Down
1 change: 0 additions & 1 deletion telegram-bot-api/src/Telegram/Bot/API/Types/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
module Telegram.Bot.API.Types.Common where

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Telegram.Bot.API.Internal.Utils
-- ** 'CopyMessageId'

-- | This object represents result of copyMessage request.
data CopyMessageId = CopyMessageId
newtype CopyMessageId = CopyMessageId
{ copyMessageIdMessageId :: MessageId -- ^ the MessageId of the sent message.
}
deriving (Generic, Show)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import Telegram.Bot.API.Internal.Utils

-- | This object represents an inline keyboard that appears
-- right next to the message it belongs to.
data InlineKeyboardMarkup = InlineKeyboardMarkup
newtype InlineKeyboardMarkup = InlineKeyboardMarkup
{ inlineKeyboardMarkupInlineKeyboard :: [[InlineKeyboardButton]] -- ^ Array of button rows, each represented by an Array of InlineKeyboardButton objects
}
deriving (Generic, Show)

-- ^
-- ^
-- **Note**: This will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.

instance ToJSON InlineKeyboardMarkup where toJSON = gtoJSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Telegram.Bot.API.Internal.Utils
-- ** 'MessageAutoDeleteTimerChanged'

-- | This object represents a service message about a change in auto-delete timer settings.
data MessageAutoDeleteTimerChanged = MessageAutoDeleteTimerChanged
newtype MessageAutoDeleteTimerChanged = MessageAutoDeleteTimerChanged
{ messageAutoDeleteTimerChangedMessageAutoDeleteTime :: Seconds -- ^ New auto-delete time for messages in the chat; in seconds
}
deriving (Generic, Show)
Expand Down
3 changes: 1 addition & 2 deletions telegram-bot-api/src/Telegram/Bot/API/Types/ReactionType.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Telegram.Bot.API.Types.ReactionType where
Expand All @@ -16,7 +15,7 @@ import qualified Data.Text as Text
-- ** 'ReactionType'

-- | This object describes the type of a reaction. Currently, it can be one of
--
--
-- * 'ReactionTypeEmoji',
-- * 'ReactionTypeCustomEmoji'.
--
Expand Down
4 changes: 2 additions & 2 deletions telegram-bot-api/src/Telegram/Bot/API/Types/VideoChatEnded.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Telegram.Bot.API.Internal.Utils
-- ** 'VideoChatEnded'

-- | This object represents a service message about a video chat ended in the chat.
data VideoChatEnded = VideoChatEnded
newtype VideoChatEnded = VideoChatEnded
{ videoChatEndedDuration :: Seconds -- ^ Video chat duration in seconds.
}
deriving (Generic, Show)
Expand All @@ -22,7 +22,7 @@ instance FromJSON VideoChatEnded where parseJSON = gparseJSON

-- ** 'VideoChatParticipantsInvited'

data VideoChatParticipantsInvited = VideoChatParticipantsInvited
newtype VideoChatParticipantsInvited = VideoChatParticipantsInvited
{ videoChatParticipantsInvitedUsers :: Maybe [User] -- ^ New members that were invited to the video chat.
}
deriving (Generic, Show)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Telegram.Bot.API.Internal.Utils
-- ** 'VideoChatScheduled'

-- | This object represents a service message about a video chat scheduled in the chat.
data VideoChatScheduled = VideoChatScheduled
newtype VideoChatScheduled = VideoChatScheduled
{ videoChatScheduledStartDate :: POSIXTime -- ^ Point in time (Unix timestamp) when the video chat is supposed to be started by a chat administrator.
}
deriving (Generic, Show)
Expand Down

0 comments on commit 027648c

Please sign in to comment.