preamble 0.0.19 → 0.0.20
raw patch · 3 files changed
+21/−5 lines, 3 files
Files
- Shakefile.hs +4/−0
- preamble.cabal +1/−1
- src/Preamble/Prelude.hs +16/−4
Shakefile.hs view
@@ -21,6 +21,10 @@ , "src//*.hs" ] + -- | Haskell rules.+ --+ hsRules "."+ -- | Cabal rules. -- cabalRules "." "preamble.cabal"
preamble.cabal view
@@ -1,5 +1,5 @@ name: preamble-version: 0.0.19+version: 0.0.20 synopsis: Yet another prelude. description: A prelude built on basic-prelude. homepage: https://github.com/swift-nav/preamble
src/Preamble/Prelude.hs view
@@ -10,7 +10,9 @@ , either' , maybe_ , eitherThrowIO+ , eitherThrowIO' , maybeThrowIO+ , maybeThrowIO' , boolThrowIO , textFromString , (-/-)@@ -40,15 +42,25 @@ maybe_ :: Monad m => Maybe a -> (a -> m ()) -> m () maybe_ = flip $ maybe $ return () +-- | Throw Exception on either error.+--+eitherThrowIO :: (MonadIO m, Exception e) => Either e a -> m a+eitherThrowIO = either (liftIO . throwIO) return+ -- | Throw userError on either error. ---eitherThrowIO :: MonadIO m => Either String a -> m a-eitherThrowIO = either (liftIO . throwIO . userError) return+eitherThrowIO' :: MonadIO m => Either String a -> m a+eitherThrowIO' = either (liftIO . throwIO . userError) return +-- | Throw Exception on maybe nothing.+--+maybeThrowIO :: (MonadIO m, Exception e) => e -> Maybe a -> m a+maybeThrowIO e = maybe (liftIO $ throwIO e) return+ -- | Throw userError on maybe nothing. ---maybeThrowIO :: MonadIO m => String -> Maybe a -> m a-maybeThrowIO s = maybe (liftIO $ throwIO $ userError s) return+maybeThrowIO' :: MonadIO m => String -> Maybe a -> m a+maybeThrowIO' s = maybe (liftIO $ throwIO $ userError s) return -- | Throw userError on false. --