-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do paged conversation lists; change the pager to be generic over types #105
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{-# LANGUAGE TemplateHaskell #-} | ||
|
||
module Web.Slack.Pager.Types where | ||
|
||
import Web.Slack.Prelude | ||
import Web.Slack.Util | ||
|
||
newtype Cursor = Cursor {unCursor :: Text} | ||
deriving stock (Eq, Generic, Show) | ||
deriving newtype (NFData, Hashable, FromJSON, ToJSON, ToHttpApiData) | ||
|
||
newtype ResponseMetadata = ResponseMetadata {responseMetadataNextCursor :: Maybe Cursor} | ||
deriving stock (Eq, Show, Generic) | ||
|
||
instance NFData ResponseMetadata | ||
|
||
$(deriveJSON (jsonOpts "responseMetadata") ''ResponseMetadata) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is simple enough write the instances without the Template Haskell overhead? Or this is simple enough the Template Haskell overhead doesn't matter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main motivation is that it was moved. I would rather take the TH overhead than do it inconsistently, I guess. |
||
|
||
class PagedRequest a where | ||
setCursor :: Maybe Cursor -> a -> a | ||
|
||
class PagedResponse a where | ||
type ResponseObject a | ||
getResponseMetadata :: a -> Maybe ResponseMetadata | ||
getResponseData :: a -> [ResponseObject a] | ||
Comment on lines
+19
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I designed it this way since there is no binding between request and response types; two requests may reuse the same response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sicko_yes.jpg