module EVM.Demand (demand) where import Control.DeepSeq (NFData, force) import Control.Exception.Base (evaluate) import Control.Monad.IO.Class (MonadIO, liftIO) -- | This is an easy way to force full evaluation of a value inside of -- the IO monad, being essentially just the composition of @evaluate@ -- and @force@. demand :: (MonadIO m, NFData a) => a -> m () demand :: a -> m () demand a x = do a _ <- IO a -> m a forall (m :: * -> *) a. MonadIO m => IO a -> m a liftIO (a -> IO a forall a. a -> IO a evaluate (a -> a forall a. NFData a => a -> a force a x)) () -> m () forall (m :: * -> *) a. Monad m => a -> m a return ()