Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{-# LANGUAGE LambdaCase #-}
import Prelude (Bool (True, False), Monad, (>>=))
ifThenElseM :: Monad m => m Bool -> m a -> m a -> m a
ifThenElseM cond ifTrue ifFalse =
cond >>= \case { True -> ifTrue; False -> ifFalse }
ifThenElseM' :: Monad m => [(m Bool, m a)] -> m a -> m a
ifThenElseM' ifs ifAllFalse =
go ifs
where
go = \case
[] -> ifAllFalse
(cond, x) : xs -> ifThenElseM cond x (go xs)
@argumatronic

This comment has been minimized.

Copy link

commented Mar 16, 2019

what are you doin over here chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.