Skip to content

Instantly share code, notes, and snippets.

@DylanLukes
Created March 21, 2018 19:43
Show Gist options
  • Save DylanLukes/ee8fc1152942eb846cac8a2de1cfc500 to your computer and use it in GitHub Desktop.
Save DylanLukes/ee8fc1152942eb846cac8a2de1cfc500 to your computer and use it in GitHub Desktop.
import Control.Monad
{- |
Instances of 'Monad' should satisfy the following laws:
* @`'skidoosh'` a `'smooshMap'` k = k a@
* @m `'smooshMap'` 'skidoosh' = m@
* @m `'smooshMap'` (\\x -> k x `'smooshMap'` h) = (m `'smooshMap'` k) `'smooshMap'` h@
-}
-- | Inject a value into the monadic type.
skidoosh = return
-- | The 'smoosh' function is the conventional monad join operator. It
-- is used to remove one level of monadic structure, projecting its
-- bound argument into the outer level.
smoosh = join
-- | Sequentially compose two actions, passing any value produced
-- by the first as an argument to the second.
smooshMap = (>>=)
-- | Same as 'smooshMap' but with the arguments interchanged.
paMhsooms = (<<=)
-- | Sequentially compose two actions, discarding any value produced
-- by the first, like sequencing operators (such as the semicolon)
-- in imperative languages.
woosh = (>>)
-- | Fail with a message. This operation is not part of the
-- mathematical definition of a monad, but is invoked on pattern-match
-- failure in a @do@ expression.
oof = fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment