data Cond a = Then a | Else a
then' :: (Monad m) => m a -> Cond (m a)
then' = Then
else' :: (Monad m) => m a -> Cond (m a)
else' = Else
if' :: (Monad m) => Bool -> Cond (m a) -> Cond (m a) -> m a
if' True (Then t) _ = t
if' False _ (Else f) = f
if' _ _ _ = error "syntax error"
main = do
if' (4 < 3)
(then' $ print "foo")
(else' $ print "bar")
if' (4 > 3)
(then' $ print "baz")
(else' $ print "bat")