{- monadic stuff
 -
 - Copyright 2010-2012 Joey Hess <id@joeyh.name>
 -
 - License: BSD-2-clause
 -}

{-# OPTIONS_GHC -fno-warn-tabs #-}

module Utility.Monad where

{- if with a monadic conditional. -}
ifM :: Monad m => m Bool -> (m a, m a) -> m a
ifM :: forall (m :: * -> *) a. Monad m => m Bool -> (m a, m a) -> m a
ifM m Bool
cond (m a
thenclause, m a
elseclause) = do
	Bool
c <- m Bool
cond
	if Bool
c then m a
thenclause else m a
elseclause

{- do nothing -}
noop :: Monad m => m ()
noop :: forall (m :: * -> *). Monad m => m ()
noop = forall (m :: * -> *) a. Monad m => a -> m a
return ()