module Incipit.Misc where
import Incipit.Base
unit ::
Applicative f =>
f ()
unit :: forall (f :: * -> *). Applicative f => f ()
unit =
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
{-# inline unit #-}
whenM ::
Monad m =>
m Bool ->
m () ->
m ()
whenM :: forall (m :: * -> *). Monad m => m Bool -> m () -> m ()
whenM m Bool
condM m ()
action =
m Bool
condM forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ Bool
cond -> forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
cond m ()
action
{-# inline whenM #-}
unlessM ::
Monad m =>
m Bool ->
m () ->
m ()
unlessM :: forall (m :: * -> *). Monad m => m Bool -> m () -> m ()
unlessM m Bool
condM m ()
action =
m Bool
condM forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ Bool
cond -> forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
cond m ()
action
{-# inline unlessM #-}
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
condM m a
onTrue m a
onFalse =
m Bool
condM forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ Bool
cond -> if Bool
cond then m a
onTrue else m a
onFalse
{-# inline ifM #-}