packages feed

calamity 0.1.8.0 → 0.1.8.1

raw patch · 3 files changed

+39/−32 lines, 3 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Calamity.Client.Types: [$sel:originalEffectsType:Client] :: Client -> TypeRep
+ Calamity.Client.Types: type ReactConstraints r s eh ehIO t = (InsertEventHandler s, RemoveEventHandler s, eh ~ EHType s (Sem r) (), ehIO ~ EHType s IO (), Uncurry eh, Uncurried eh ~ (t -> Sem r ()), Curry (t -> IO ()), ehIO ~ Curried (t -> IO ()))
+ Calamity.Client.Types: type WaitUntilConstraints r s eh ehB t = (InsertEventHandler s, RemoveEventHandler s, Uncurry eh, eh ~ EHType s (Sem r) (), eh ~ Curried (t -> Sem r ()), Uncurry ehB, Uncurried ehB ~ (t -> Sem r Bool), Curry (t -> IO ()), Curried (t -> IO ()) ~ EHType s IO ())
- Calamity.Client.Client: react :: forall (s :: EventType) r t eh ehIO. (BotC r, InsertEventHandler s, RemoveEventHandler s, eh ~ EHType s (Sem r) (), ehIO ~ EHType s IO (), Uncurry eh, Uncurried eh ~ (t -> Sem r ()), Curry (t -> IO ()), ehIO ~ Curried (t -> IO ())) => eh -> Sem r (Sem r ())
+ Calamity.Client.Client: react :: forall (s :: EventType) r t eh ehIO. (BotC r, ReactConstraints r s eh ehIO t) => EHType s (Sem r) () -> Sem r (Sem r ())
- Calamity.Client.Client: waitUntil :: forall (s :: EventType) r t eh ehB. (BotC r, InsertEventHandler s, RemoveEventHandler s, Uncurry eh, eh ~ EHType s (Sem r) (), eh ~ Curried (t -> Sem r ()), Uncurry ehB, Uncurried ehB ~ (t -> Sem r Bool), Curry (t -> IO ()), Curried (t -> IO ()) ~ EHType s IO ()) => ehB -> Sem r t
+ Calamity.Client.Client: waitUntil :: forall (s :: EventType) r t eh ehB. (BotC r, WaitUntilConstraints r s eh ehB t) => ehB -> Sem r t
- Calamity.Client.Types: Client :: TVar [(InChan ControlMessage, Async (Maybe ()))] -> MVar Int -> Token -> RateLimitState -> InChan CalamityEvent -> OutChan CalamityEvent -> IORef Integer -> TypeRep -> Client
+ Calamity.Client.Types: Client :: TVar [(InChan ControlMessage, Async (Maybe ()))] -> MVar Int -> Token -> RateLimitState -> InChan CalamityEvent -> OutChan CalamityEvent -> IORef Integer -> Client

Files

calamity.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 1217175ab8de3749a8fdae8f73f44a650fbb177f93f65f8c2d583dea7cffec7c+-- hash: 2763f995fb4b7a5e41a214cd6a7d841b9c99817d27924c59d216ff0271005b8b  name:           calamity-version:        0.1.8.0+version:        0.1.8.1 synopsis:       A library for writing discord bots description:    Please see the README on GitHub at <https://github.com/nitros12/calamity#readme> category:       Network, Web
src/Calamity/Client/Client.hs view
@@ -67,8 +67,8 @@   pure (duration, res)  -newClient :: Token -> TypeRep -> IO Client-newClient token t = do+newClient :: Token -> IO Client+newClient token = do   shards'        <- newTVarIO []   numShards'     <- newEmptyMVar   rlState'       <- newRateLimitState@@ -82,12 +82,11 @@                 inc                 outc                 ehidCounter-                t  -- | Create a bot, run your setup action, and then loop until the bot closes. runBotIO :: forall r a. (P.Members '[P.Embed IO, P.Final IO, CacheEff, MetricEff] r, Typeable (SetupEff r)) => Token -> P.Sem (SetupEff r) a -> P.Sem r (Maybe StartupError) runBotIO token setup = do-  client <- P.embed $ newClient token (typeRep $ Proxy @(SetupEff r))+  client <- P.embed $ newClient token   handlers <- P.embed $ newTVarIO def   P.asyncToIOFinal . P.runAtomicStateTVar handlers . P.runReader client . Di.runDiToStderrIO . Di.push "calamity" $ do     void $ Di.push "calamity-setup" setup@@ -133,20 +132,11 @@ -- since if something doesn't match then 'EHType' might not get substituted, -- which will result in errors about parameter counts mismatching. react :: forall (s :: EventType) r t eh ehIO.-      (BotC r-      , InsertEventHandler s-      , RemoveEventHandler s-      , eh ~ EHType s (P.Sem r) ()-      , ehIO ~ EHType s IO ()-      , Uncurry eh-      , Uncurried eh ~ (t -> P.Sem r ())-      , Curry (t -> IO ())-      , ehIO ~ Curried (t -> IO ())-      )-      => eh+      (BotC r, ReactConstraints r s eh ehIO t)+      => EHType s (P.Sem r) ()       -> P.Sem r (P.Sem r ()) react handler = do-  handler' <- ehToIO (\(params :: t) -> (uncurryG handler params))+  handler' <- ehToIO $ uncurryG handler   ehidC <- P.asks (^. #ehidCounter)   id' <- P.embed $ atomicModifyIORef ehidC (\i -> (succ i, i))   let handlers = makeEventHandlers (Proxy @s) id' (curryG handler')@@ -196,8 +186,7 @@ -- | Wait until an event satisfying a condition happens, then returns it's -- parameters ----- Sorry about this horrendous type sig, this is what it would look like with @s--- ~ \''MessageCreateEvt'@:+-- This is what it would look like with @s ~ \''MessageCreateEvt'@: -- -- @ -- 'waitUntil' :: ('Message' -> 'P.Sem' r 'Bool') -> 'P.Sem' r 'Message'@@ -219,17 +208,7 @@ -- @ waitUntil   :: forall (s :: EventType) r t eh ehB.-  ( BotC r-  , InsertEventHandler s-  , RemoveEventHandler s-  , Uncurry eh-  , eh ~ EHType s (P.Sem r) ()-  , eh ~ Curried (t -> P.Sem r ())-  , Uncurry ehB-  , Uncurried ehB ~ (t -> P.Sem r Bool)-  , Curry (t -> IO ())-  , Curried (t -> IO ()) ~ EHType s IO ()-  )+  ( BotC r, WaitUntilConstraints r s eh ehB t)   => ehB   -> P.Sem r t waitUntil f = do
src/Calamity/Client/Types.hs view
@@ -6,6 +6,8 @@     , EHType     , BotC     , SetupEff+    , ReactConstraints+    , WaitUntilConstraints     , EventHandlers(..)     , InsertEventHandler(..)     , RemoveEventHandler(..)@@ -16,6 +18,7 @@ import           Calamity.Gateway.DispatchEvents ( CalamityEvent(..), ReadyData ) import           Calamity.Gateway.Types          ( ControlMessage ) import           Calamity.HTTP.Internal.Types+import           Calamity.Internal.GenericCurry import           Calamity.Metrics.Eff import           Calamity.Types.LogEff import           Calamity.Types.Model.Channel@@ -56,7 +59,6 @@   , eventsIn            :: InChan CalamityEvent   , eventsOut           :: OutChan CalamityEvent   , ehidCounter         :: IORef Integer-  , originalEffectsType :: TypeRep   }   deriving ( Generic ) @@ -67,6 +69,32 @@  -- | A concrete effect stack used inside the bot type SetupEff r = (LogEff ': P.Reader Client ': P.AtomicState EventHandlers ': P.Async ': r)++-- | Some constraints that 'Calamity.Client.Client.react' needs to work. Don't+-- worry about these since they are satisfied for any type @s@ can be+type ReactConstraints r s eh ehIO t =+  ( InsertEventHandler s+  , RemoveEventHandler s+  , eh ~ EHType s (P.Sem r) ()+  , ehIO ~ EHType s IO ()+  , Uncurry eh+  , Uncurried eh ~ (t -> P.Sem r ())+  , Curry (t -> IO ())+  , ehIO ~ Curried (t -> IO ()))++-- | Some constraints that 'Calamity.Client.Client.waitUntil' needs to work. Don't+-- worry about these since they are satisfied for any type @s@ can be+type WaitUntilConstraints r s eh ehB t =+  ( InsertEventHandler s+  , RemoveEventHandler s+  , Uncurry eh+  , eh ~ EHType s (P.Sem r) ()+  , eh ~ Curried (t -> P.Sem r ())+  , Uncurry ehB+  , Uncurried ehB ~ (t -> P.Sem r Bool)+  , Curry (t -> IO ())+  , Curried (t -> IO ()) ~ EHType s IO ()+  )  newtype StartupError = StartupError String   deriving ( Show )