on b52ed84 help sign in
28 lines 693 B history raw
1-- |
2-- Module : Streamly.Internal.Control.Monad
3-- Copyright : (c) 2019 Composewell Technologies
4--
5-- License : BSD3
6-- Maintainer : streamly@composewell.com
7-- Stability : experimental
8-- Portability : GHC
9--
10-- Additional "Control.Monad" utilities.
12{-# LANGUAGE ScopedTypeVariables #-}
14module Streamly.Internal.Control.Monad
15 ( discard
16 )
17where
19import Control.Monad (void)
20import Control.Monad.Catch (MonadCatch, catch, SomeException)
22-- | Discard any exceptions or value returned by an effectful action.
23--
24-- /Internal/
25--
26{-# INLINE discard #-}
27discard :: MonadCatch m => m b -> m ()
28discard action = (void $ action) `catch` (\(_ :: SomeException) -> return ())