little-rio 0.2.1 → 0.2.2
raw patch · 3 files changed
+20/−8 lines, 3 filesdep +deepseq
Dependencies added: deepseq
Files
- LICENSE +2/−2
- little-rio.cabal +3/−2
- src/LittleRIO.hs +15/−4
LICENSE view
@@ -1,4 +1,4 @@-Copyright Author name here (c) 2020+Copyright Eric Conlon (c) 2020 All rights reserved. @@ -13,7 +13,7 @@ disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Author name here nor the names of other+ * Neither the name of Eric Conlon nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
little-rio.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: c4d3676360878246e0cc19b1cd117171bed224a6f806b03e54e033317210f478+-- hash: 5ac2b5e5c9651242e6bae46a58a6674da57dbc16daeff53478cb3b2d8b383e0e name: little-rio-version: 0.2.1+version: 0.2.2 synopsis: When you need just the RIO monad description: Please see the README on GitHub at <https://github.com/ejconlon/little-rio#readme> category: Control@@ -36,6 +36,7 @@ ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints -fno-warn-unused-top-binds build-depends: base >=4.12 && <5+ , deepseq >=1.4.4.0 && <2 , exceptions >=0.10 && <1 , microlens >=0.4 && <1 , microlens-mtl >=0.2 && <1
src/LittleRIO.hs view
@@ -1,4 +1,7 @@+{-# LANGUAGE DeriveAnyClass #-}+{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveTraversable #-}+{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -42,6 +45,7 @@ ) where import Control.Applicative (liftA2)+import Control.DeepSeq (NFData (..)) import Control.Monad.Catch (MonadCatch, MonadMask, MonadThrow) import Control.Monad.IO.Class (MonadIO (..)) import Control.Monad.IO.Unlift (MonadUnliftIO (..), UnliftIO, askUnliftIO)@@ -52,12 +56,13 @@ import Control.Monad.Trans.Resource.Internal (MonadResource (..), ReleaseMap, ResourceT (..)) import Control.Monad.Writer (MonadWriter (..)) import Data.IORef (IORef, newIORef, readIORef, writeIORef)+import GHC.Generics (Generic) import Lens.Micro (Lens', lens) import Lens.Micro.Mtl (view) import Prelude newtype RIO env a = RIO { unRIO :: ReaderT env IO a }- deriving (Functor, Applicative, Monad, MonadReader env, MonadIO, MonadThrow, MonadFail, MonadCatch, MonadMask, MonadUnliftIO)+ deriving newtype (Functor, Applicative, Monad, MonadReader env, MonadIO, MonadThrow, MonadFail, MonadCatch, MonadMask, MonadUnliftIO) instance Semigroup a => Semigroup (RIO env a) where (<>) = liftA2 (<>)@@ -89,6 +94,9 @@ data SomeRef a = SomeRef !(IO a) !(a -> IO ()) +instance NFData (SomeRef a) where+ rnf (SomeRef r w) = seq r (seq w ())+ readSomeRef :: MonadIO m => SomeRef a -> m a readSomeRef (SomeRef x _) = liftIO x @@ -113,7 +121,8 @@ data SimpleStateEnv st env = SimpleStateEnv { sseRef :: !(SomeRef st) , sseEnv :: !env- } deriving (Functor, Foldable, Traversable)+ } deriving stock (Functor, Foldable, Traversable, Generic)+ deriving anyclass (NFData) instance HasStateRef st (SimpleStateEnv st env) where stateRefL = lens sseRef (\(SimpleStateEnv _ env) st -> SimpleStateEnv st env)@@ -153,7 +162,8 @@ data SimpleWriteEnv w env = SimpleWriteEnv { sweRef :: !(SomeRef w) , sweEnv :: !env- } deriving (Functor, Foldable, Traversable)+ } deriving stock (Functor, Foldable, Traversable, Generic)+ deriving anyclass (NFData) instance HasWriteRef w (SimpleWriteEnv w env) where writeRefL = lens sweRef (\(SimpleWriteEnv _ env) w -> SimpleWriteEnv w env)@@ -208,7 +218,8 @@ data SimpleResourceEnv env = SimpleResourceEnv { sreMap :: !ResourceMap , sreEnv :: !env- } deriving (Functor, Foldable, Traversable)+ } deriving stock (Functor, Foldable, Traversable, Generic)+ deriving anyclass (NFData) instance HasResourceMap (SimpleResourceEnv env) where resourceMapL = lens sreMap (\(SimpleResourceEnv _ env) m -> SimpleResourceEnv m env)