discord-hs 0.2.2 → 0.3.2
raw patch · 2 files changed
+16/−7 lines, 2 filesdep +comonad
Dependencies added: comonad
Files
- discord-hs.cabal +2/−1
- src/Network/Discord/Rest/Prelude.hs +14/−6
discord-hs.cabal view
@@ -1,5 +1,5 @@ name: discord-hs-version: 0.2.2+version: 0.3.2 synopsis: An API wrapper for Discord in Haskell description: Provides an api wrapper and framework for writing bots against the Discord <https://discordapp.com/> API.@@ -43,6 +43,7 @@ , aeson>=1.0 && <1.2 , bytestring==0.10.* , case-insensitive==1.2.*+ , comonad==5.* , containers==0.5.* , data-default==0.7.* , hashable==1.2.*
src/Network/Discord/Rest/Prelude.hs view
@@ -4,7 +4,8 @@ -- | Utility and base types and functions for the Discord Rest API module Network.Discord.Rest.Prelude where import Control.Concurrent (threadDelay)- ++ import Control.Comonad import Control.Concurrent.STM import Data.Aeson import Data.Default@@ -55,7 +56,7 @@ threadDelay $ 1000000 * (a - now) putStrLn "Done" return ()- + -- | Class over which performing a data retrieval action is defined class DoFetch a where doFetch :: a -> DiscordM Fetched@@ -74,16 +75,23 @@ -- | Result of a data retrieval action data Fetched = forall a. (FromJSON a) => SyncFetched a- ++ instance Functor Fetched where+ fmap f (SyncFetched a) = SyncFetched (f a)++ instance Comonad Fetched where+ extend = (SyncFetched .)+ extract (SyncFetched a) = a+ -- | Represents a range of 'Snowflake's data Range = Range { after :: Snowflake, before :: Snowflake, limit :: Int} instance Default Range where def = Range 0 18446744073709551615 100- + -- | Convert a Range to a query string toQueryString :: Range -> Option 'Https toQueryString (Range a b l)- = "after" =: show a - <> "before" =: show b + = "after" =: show a+ <> "before" =: show b <> "limit" =: show l