protolude 0.1.7 → 0.1.8
raw patch · 3 files changed
+41/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Exceptions: hush :: Alternative m => Either e a -> m a
+ Exceptions: note :: (MonadError e m, Applicative m) => e -> Maybe a -> m a
+ Exceptions: tryIO :: MonadIO m => IO a -> ExceptT IOException m a
+ Protolude: foreach :: Functor f => f a -> (a -> b) -> f b
+ Protolude: pass :: Applicative f => f ()
Files
- protolude.cabal +2/−1
- src/Exceptions.hs +28/−0
- src/Protolude.hs +11/−0
protolude.cabal view
@@ -1,5 +1,5 @@ name: protolude-version: 0.1.7+version: 0.1.8 synopsis: A sensible set of defaults for writing custom Preludes. description: A sensible set of defaults for writing custom Preludes. homepage: https://github.com/sdiehl/protolude@@ -46,6 +46,7 @@ Functor Semiring Bifunctor+ Exceptions Panic other-modules:
+ src/Exceptions.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE NoImplicitPrelude #-}++module Exceptions (+ hush,+ note,+ tryIO,+) where++import Base (IO)+import Data.Function ((.))+import Control.Monad.Trans (liftIO)+import Control.Monad.IO.Class (MonadIO)+import Control.Monad.Except (ExceptT(..), MonadError, throwError)+import Control.Exception as Exception+import Control.Applicative+import Data.Maybe (Maybe, maybe)+import Data.Either (Either(..))++hush :: Alternative m => Either e a -> m a+hush (Left _) = empty+hush (Right x) = pure x++note :: (MonadError e m, Applicative m) => e -> Maybe a -> m a+note err = maybe (throwError err) pure++tryIO :: MonadIO m => IO a -> ExceptT IOException m a+tryIO = ExceptT . liftIO . Exception.try
src/Protolude.hs view
@@ -17,7 +17,9 @@ print, throwIO, throwTo,+ foreach, show,+ pass, LText, LByteString,@@ -33,6 +35,7 @@ import Applicative as X import Conv as X import Panic as X+import Exceptions as X import Base as Base hiding ( putStr -- Overriden by Show.putStr@@ -335,6 +338,7 @@ , throwTo , assert , displayException+ , Handler(..) ) import qualified Control.Exception@@ -342,6 +346,7 @@ import Control.Monad.STM as X import Control.Concurrent as X hiding ( throwTo+ , yield ) import Control.Concurrent.Async as X @@ -392,6 +397,12 @@ throwTo :: (X.MonadIO m, Exception e) => ThreadId -> e -> m () throwTo tid e = liftIO (Control.Exception.throwTo tid e)++foreach :: Functor f => f a -> (a -> b) -> f b+foreach = flip fmap++pass :: Applicative f => f ()+pass = pure () show :: (Show a, StringConv String b) => a -> b show x = toS (PBase.show x)