Safe Haskell | None |
---|---|
Language | Haskell2010 |
- convertStringToRawByteString :: MonadIO m => String -> m ByteString
- openFilePathForReading :: MonadIO m => FilePath -> m (Either IOException Handle)
- combineApplicatives :: (Applicative f, Semigroup a) => f a -> f a -> f a
- closeHandleIfEOFOrThrow :: MonadIO m => Handle -> IOException -> m ()
- die :: Int -> String -> IO a
- whenNonNull :: Monad m => [a] -> m () -> m ()
- modify' :: MonadState s m => (s -> s) -> m ()
Documentation
convertStringToRawByteString :: MonadIO m => String -> m ByteString Source #
Convert a String
to a ByteString
with the encoding for the current
locale.
>>>
convertStringToRawByteString "hello"
"hello"
openFilePathForReading :: MonadIO m => FilePath -> m (Either IOException Handle) Source #
combineApplicatives :: (Applicative f, Semigroup a) => f a -> f a -> f a Source #
Combine values in two Applicative
s with <>
.
>>>
combineApplicatives (Just "hello") (Just " world")
Just "hello world"
>>>
combineApplicatives (Just "hello") Nothing
Nothing
closeHandleIfEOFOrThrow :: MonadIO m => Handle -> IOException -> m () Source #
Handle an IOException
that occurs when reading from a Handle
. Check
if the IOException
is an EOF exception (hIsEOF
). If so, then just close
the Handle
. Otherwise, throw the IOException
that is passed in.
Call exitWith
with ExitFailure
>>>
die 10 "message"
ERROR: message *** Exception: ExitFailure 10
whenNonNull :: Monad m => [a] -> m () -> m () Source #
Perform an action when a list is non-null.
>>>
whenNonNull [1,2,3] $ putStrLn "hello"
hello>>>
whenNonNull [] $ putStrLn "bye"