commander-cli-0.8.0.0: A command line argument/option parser library

Copyright(c) Samuel Schlesinger 2020
LicenseMIT
Maintainersgschlesinger@gmail.com
Stabilityexperimental
PortabilityPOSIX, Windows
Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Commander

Contents

Description

 
Synopsis

The CommanderT Monad

The CommanderT monad is how your CLI programs are interpreted by run. It has the ability to backtrack and it maintains some state.

data CommanderT state m a Source #

A CommanderT action is a metaphor for a military commander. At each step, we have a new Action to take, or we could have experienced Defeat, or we can see Victory. While a real life commander worries about moving his troops around in order to achieve a victory in battle, a CommanderT worries about iteratively transforming a state to find some value. We will deal with the subset of these actions where every function must decrease the size of the state, as those are the actions for which this is a monad.

Constructors

Action (state -> m (CommanderT state m a, state)) 
Defeat 
Victory a 
Instances
MonadTrans (CommanderT state) Source # 
Instance details

Defined in Control.Monad.Commander

Methods

lift :: Monad m => m a -> CommanderT state m a #

Monad m => Monad (CommanderT state m) Source # 
Instance details

Defined in Control.Monad.Commander

Methods

(>>=) :: CommanderT state m a -> (a -> CommanderT state m b) -> CommanderT state m b #

(>>) :: CommanderT state m a -> CommanderT state m b -> CommanderT state m b #

return :: a -> CommanderT state m a #

fail :: String -> CommanderT state m a #

Functor m => Functor (CommanderT state m) Source # 
Instance details

Defined in Control.Monad.Commander

Methods

fmap :: (a -> b) -> CommanderT state m a -> CommanderT state m b #

(<$) :: a -> CommanderT state m b -> CommanderT state m a #

Monad m => Applicative (CommanderT state m) Source # 
Instance details

Defined in Control.Monad.Commander

Methods

pure :: a -> CommanderT state m a #

(<*>) :: CommanderT state m (a -> b) -> CommanderT state m a -> CommanderT state m b #

liftA2 :: (a -> b -> c) -> CommanderT state m a -> CommanderT state m b -> CommanderT state m c #

(*>) :: CommanderT state m a -> CommanderT state m b -> CommanderT state m b #

(<*) :: CommanderT state m a -> CommanderT state m b -> CommanderT state m a #

MonadIO m => MonadIO (CommanderT state m) Source # 
Instance details

Defined in Control.Monad.Commander

Methods

liftIO :: IO a -> CommanderT state m a #

Monad m => Alternative (CommanderT state m) Source # 
Instance details

Defined in Control.Monad.Commander

Methods

empty :: CommanderT state m a #

(<|>) :: CommanderT state m a -> CommanderT state m a -> CommanderT state m a #

some :: CommanderT state m a -> CommanderT state m [a] #

many :: CommanderT state m a -> CommanderT state m [a] #

runCommanderT :: Monad m => CommanderT state m a -> state -> m (Maybe a) Source #

We can run a CommanderT action on a state and see if it has a successful campaign.