if-0.1.0.0: (?) and (?>) conditional operator

Copyright(c) Winterland, 2016
LicenseBSD
Maintainerdrkoster@qq.com
Stabilitystable
PortabilityPORTABLE
Safe HaskellSafe
LanguageHaskell2010

If

Description

This module provides two simple operators ? and ?> for simple conditions. Watch out for boolean blindness if you use them too often.

Synopsis

Documentation

(?) :: Bool -> a -> a -> a infixr 1 Source

This is the if-then-else operator, With it you can write xxx ? yyy $ zzz instead of if xxx then yyy else zzz. Following may or may not be cleaner to you ; )

  isFoo <- checkFoo
  isFoo ? foo
        $ bar

(?>) :: Monad m => m Bool -> m () -> m () infixl 1 Source

This is the whenM operator, With it you can write doesItExists ?> removeIt instead of do {e <- doesItExists; when e removeIt}. There's not unlessM version, so you have to use not.

  not <$> doesItExists ?> createIt