packages feed

rfc 0.0.0.16 → 0.0.0.17

raw patch · 12 files changed

+50/−30 lines, 12 filesdep ~classy-preludePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: classy-prelude

API changes (from Hackage documentation)

+ RFC.Prelude: throw :: (MonadIO m, Exception e) => e -> m a
+ RFC.Prelude: throwM :: (MonadIO m, Exception e) => e -> m a
- RFC.Google.Places.NearbySearch: class (MonadThrow m, MonadIO m) => HasAPIClient m
+ RFC.Google.Places.NearbySearch: class (MonadIO m) => HasAPIClient m
- RFC.Google.Places.NearbySearch: query :: (HasAPIClient m, MonadCatch m) => Params -> m Results
+ RFC.Google.Places.NearbySearch: query :: (HasAPIClient m, MonadUnliftIO m) => Params -> m Results
- RFC.Google.Places.PlaceSearch: class (MonadThrow m, MonadIO m) => HasAPIClient m
+ RFC.Google.Places.PlaceSearch: class (MonadIO m) => HasAPIClient m
- RFC.Google.Places.PlaceSearch: query :: (MonadCatch m, HasAPIClient m) => Params -> m Results
+ RFC.Google.Places.PlaceSearch: query :: (MonadUnliftIO m, HasAPIClient m) => Params -> m Results
- RFC.HTTP.Client: apiGet :: (HasAPIClient m, FromJSON a, MonadCatch m, Exception e) => URL -> (e -> m a) -> m a
+ RFC.HTTP.Client: apiGet :: (HasAPIClient m, FromJSON a, MonadUnliftIO m, Exception e) => URL -> (e -> m a) -> m a
- RFC.HTTP.Client: class (MonadThrow m, MonadIO m) => HasAPIClient m
+ RFC.HTTP.Client: class (MonadIO m) => HasAPIClient m
- RFC.JSON: decodeOrDie :: (FromJSON a, MonadThrow m) => LazyByteString -> m a
+ RFC.JSON: decodeOrDie :: (FromJSON a, MonadIO m) => LazyByteString -> m a
- RFC.Psql: class (MonadIO m, MonadCatch m, MonadBaseControl IO m) => HasPsql m
+ RFC.Psql: class (MonadIO m, MonadBaseControl IO m) => HasPsql m
- RFC.Redis: class (MonadIO m, MonadThrow m) => HasRedis m
+ RFC.Redis: class (MonadIO m) => HasRedis m
- RFC.Redis: setex :: (HasRedis m, ConvertibleToSBS key, ConvertibleToSBS value, TimeUnit expiry) => key -> value -> expiry -> m ()
+ RFC.Redis: setex :: (MonadIO m, HasRedis m, ConvertibleToSBS key, ConvertibleToSBS value, TimeUnit expiry) => key -> value -> expiry -> m ()

Files

rfc.cabal view
@@ -1,5 +1,5 @@ name:                rfc-version:             0.0.0.16+version:             0.0.0.17 synopsis:            Robert Fischer's Common library description:         An enhanced Prelude and various utilities for Aeson, Servant, PSQL, and Redis that Robert Fischer uses. homepage:            https://github.com/RobertFischer/rfc#README.md@@ -33,7 +33,7 @@     ghc-options:       -Werror   build-depends:       base >= 4.7 && < 5                      , servant-                     , classy-prelude+                     , classy-prelude >= 1.4.0                      , uuid-types                      , containers                      , unordered-containers
src/RFC/Concurrent.hs view
@@ -9,7 +9,8 @@  import           Control.Concurrent.Async.Lifted (mapConcurrently,                                                   mapConcurrently_)-import           RFC.Prelude                     hiding (mapConcurrently)+import           RFC.Prelude                     hiding (mapConcurrently,+                                                  mapConcurrently_)  -- |Executes all the IO actions simultaneously and returns the original data structure with the arguments replaced --  by the results of the execution.
src/RFC/Data/IdAnd.hs view
@@ -32,7 +32,7 @@   -- Don't need the backflips for maps #else import           Data.Aeson.Types                     (Parser, typeMismatch)-import           Data.Bitraversable+-- import           Data.Bitraversable import qualified Data.HashMap.Lazy                    as HashMap #endif 
src/RFC/Google/Places/NearbySearch.hs view
@@ -77,10 +77,10 @@   where     fold = flip add_param -query :: (HasAPIClient m, MonadCatch m) => Params -> m Results+query :: (HasAPIClient m, MonadUnliftIO m) => Params -> m Results query params = apiGet (paramsToUrl params) onError   where-    onError :: (MonadIO m) => SomeException -> m Results+    onError :: (MonadUnliftIO m) => SomeException -> m Results     onError err = do       logWarn . cs $ "Error performing Google Nearby Search: " ++ (show err)       return $ Results (show err, [])
src/RFC/Google/Places/PlaceSearch.hs view
@@ -60,7 +60,7 @@   where     fold = flip add_param -query :: (MonadCatch m, HasAPIClient m) => Params -> m Results+query :: (MonadUnliftIO m, HasAPIClient m) => Params -> m Results query params = apiGet (paramsToUrl params) onError   where     onError :: (MonadIO m) => SomeException -> m Results
src/RFC/HTTP/Client.hs view
@@ -38,14 +38,14 @@     let status = response ^. responseStatus     case status ^. statusCode of       200 -> converter . cs $ response ^. responseBody-      _   -> throwM $ badResponseStatus status+      _   -> throwIO $ badResponseStatus status   where     url = exportURL rawUrl     badResponseStatus status = BadStatusException (status, rawUrl) -apiGet :: (HasAPIClient m, FromJSON a, MonadCatch m, Exception e) => URL -> (e -> m a) -> m a+apiGet :: (HasAPIClient m, FromJSON a, MonadUnliftIO m, Exception e) => URL -> (e -> m a) -> m a apiGet url onError =     handle onError $ apiExecute url get decodeOrDie -class (MonadThrow m, MonadIO m) => HasAPIClient m where+class (MonadIO m) => HasAPIClient m where   getAPIClient :: m Session
src/RFC/JSON.hs view
@@ -68,10 +68,10 @@ newtype DecodeError = DecodeError (LazyByteString, String) deriving (Show,Eq,Ord,Generic,Typeable) instance Exception DecodeError -decodeOrDie :: (FromJSON a, MonadThrow m) => LazyByteString -> m a+decodeOrDie :: (FromJSON a, MonadIO m) => LazyByteString -> m a decodeOrDie input =   case decodeEither' input of-    Left err -> throwM $ DecodeError (input, err)+    Left err -> throwIO $ DecodeError (input, err)     Right a  -> return a  instance FromHttpApiData JSON.Value where
src/RFC/Log.hs view
@@ -11,7 +11,7 @@ import           Control.Logger.Simple as Log import           RFC.Env               as Env import           RFC.Prelude-import           System.IO             (BufferMode (..), hSetBuffering, stderr)+import           System.IO             (BufferMode (..), stderr)  withLogging :: IO a -> IO a withLogging action = do
src/RFC/Prelude.hs view
@@ -8,20 +8,32 @@   , module Data.Time.Units   , module Data.Function   , module Data.Typeable+  , module Control.Monad+  , module Data.Bitraversable+  , module Data.Bifunctor+  , module Data.Bifoldable+  , module Data.Default+  , module Control.Monad.Trans.Control   ) where -import           ClassyPrelude           hiding (Day, Handler, unpack)-import           Data.Char               as Char-import           Data.Function           ((&))-import qualified Data.List               as List-import           Data.String.Conversions (LazyByteString, LazyText,-                                          StrictByteString, StrictText, cs)+import           ClassyPrelude               hiding (Day, Handler, unpack)+import           Control.Monad               (forever, void, (<=<), (>=>))+import           Control.Monad.Trans.Control+import           Data.Bifoldable+import           Data.Bifunctor+import           Data.Bitraversable+import           Data.Char                   as Char+import           Data.Default+import           Data.Function               ((&))+import qualified Data.List                   as List+import           Data.String.Conversions     (LazyByteString, LazyText,+                                              StrictByteString, StrictText, cs) import           Data.Time.Units-import           Data.Typeable           (TypeRep, typeOf)-import           GHC.Generics            (Generic)-import           Prelude                 ()-import           RFC.Data.UUID           (UUID)-import           Text.Read               (Read, read)+import           Data.Typeable               (TypeRep, typeOf)+import           GHC.Generics                (Generic)+import           Prelude                     ()+import           RFC.Data.UUID               (UUID)+import           Text.Read                   (Read, read)  charIsUpper :: Char -> Bool charIsUpper = Char.isUpper@@ -41,5 +53,11 @@ safeHead :: [a] -> Maybe a safeHead []    = Nothing safeHead (x:_) = Just x++throwM :: (MonadIO m, Exception e) => e -> m a+throwM = throwIO++throw :: (MonadIO m, Exception e) => e -> m a+throw = throwIO  type Boolean = Bool -- I keep forgetting which Haskell uses....
src/RFC/Psql.hs view
@@ -35,7 +35,7 @@  type ConnectionPool = Pool Connection -class (MonadIO m, MonadCatch m, MonadBaseControl IO m) => HasPsql m where+class (MonadIO m, MonadBaseControl IO m) => HasPsql m where   getPsqlPool :: m ConnectionPool    withPsqlConnection :: (Connection -> m a) -> m a
src/RFC/Redis.hs view
@@ -21,7 +21,7 @@ newtype RedisException = RedisException R.Reply deriving (Typeable, Show) instance Exception RedisException -class (MonadIO m, MonadThrow m) => HasRedis m where+class (MonadIO m) => HasRedis m where   getRedisPool :: m ConnectionPool    runRedis :: R.Redis a -> m a@@ -40,11 +40,11 @@   maybeResult <- unpack result   return $ cs <$> maybeResult -unpack :: (MonadThrow m) => Either R.Reply a -> m a+unpack :: (MonadIO m) => Either R.Reply a -> m a unpack (Left reply) = throw $ RedisException reply unpack (Right it)   = return it -setex :: (HasRedis m, ConvertibleToSBS key, ConvertibleToSBS value, TimeUnit expiry) => key -> value -> expiry -> m ()+setex :: (MonadIO m, HasRedis m, ConvertibleToSBS key, ConvertibleToSBS value, TimeUnit expiry) => key -> value -> expiry -> m () setex key value expiry = do     result <- runRedis $ R.setex (cs key) milliseconds (cs value)     _ <- unpack result
src/RFC/Servant.hs view
@@ -24,6 +24,7 @@   , module RFC.API   ) where +import           Control.Monad.Catch        (handleJust) import           Data.Aeson                 as JSON import qualified Data.Aeson.Diff            as JSON import           Data.Swagger               (Swagger, ToSchema)@@ -33,7 +34,7 @@ import           RFC.Data.IdAnd import           RFC.HTTP.Client import           RFC.JSON                   ()-import           RFC.Prelude+import           RFC.Prelude                hiding (handleJust) import qualified RFC.Psql                   as Psql import qualified RFC.Redis                  as Redis import           Servant@@ -161,7 +162,7 @@ handleDupes =     handleJust isDuplicate throwUp   where-    throwUp err = throwError $ err409+    throwUp err = throw $ err409       { errReasonPhrase = cs $ sqlErrorMsg err       , errBody = cs $ sqlErrorDetail err       }