| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Photoname.Common
Synopsis
- newtype Artist = Artist String
- newtype ConfigPath = ConfigPath FilePath
- newtype CopySwitch = CopySwitch {}
- newtype DestPath = DestPath FilePath
- data Extension
- data Links
- newtype MoveSwitch = MoveSwitch {}
- newtype NoActionSwitch = NoActionSwitch {}
- newtype NoDirsSwitch = NoDirsSwitch {}
- newtype ParentDir = ParentDir {}
- data Options = Options {}
- type Ph a = ReaderT Options (ExceptT String IO) a
- newtype Prefix = Prefix {}
- newtype SrcPath = SrcPath {}
- newtype Suffix = Suffix {}
- data Verbosity
- defaultDateTimeFormat :: String
- readVerbosity :: String -> Either String Verbosity
- runRename :: Options -> Ph a -> IO (Either String a)
- class Monad m => MonadError e (m :: Type -> Type) | m -> e
- ask :: MonadReader r m => m r
- asks :: MonadReader r m => (r -> a) -> m a
- liftIO :: MonadIO m => IO a -> m a
- throwError :: MonadError e m => e -> m a
Documentation
newtype ConfigPath Source #
Constructors
| ConfigPath FilePath |
newtype CopySwitch Source #
Constructors
| CopySwitch | |
newtype MoveSwitch Source #
Constructors
| MoveSwitch | |
newtype NoActionSwitch Source #
Constructors
| NoActionSwitch | |
newtype NoDirsSwitch Source #
Constructors
| NoDirsSwitch | |
Constructors
| Options | |
Fields
| |
class Monad m => MonadError e (m :: Type -> Type) | m -> e #
The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.
Is parameterized over the type of error information and
the monad type constructor.
It is common to use as the monad type constructor
for an error monad in which error descriptions take the form of strings.
In that case and many other common cases the resulting monad is already defined
as an instance of the Either StringMonadError class.
You can also define your own error type and/or use a monad type constructor
other than or Either String.
In these cases you will have to explicitly define instances of the Either IOErrorMonadError
class.
(If you are using the deprecated Control.Monad.Error or
Control.Monad.Trans.Error, you may also have to define an Error instance.)
Minimal complete definition
Instances
ask :: MonadReader r m => m r #
Retrieves the monad environment.
Arguments
| :: MonadReader r m | |
| => (r -> a) | The selector function to apply to the environment. |
| -> m a |
Retrieves a function of the current environment.
liftIO :: MonadIO m => IO a -> m a #
Lift a computation from the IO monad.
This allows us to run IO computations in any monadic stack, so long as it supports these kinds of operations
(i.e. IO is the base monad for the stack).
Example
import Control.Monad.Trans.State -- from the "transformers" library printState :: Show s => StateT s IO () printState = do state <- get liftIO $ print state
Had we omitted , we would have ended up with this error:liftIO
• Couldn't match type ‘IO’ with ‘StateT s IO’ Expected type: StateT s IO () Actual type: IO ()
The important part here is the mismatch between StateT s IO () and .IO ()
Luckily, we know of a function that takes an and returns an IO a(m a): ,
enabling us to run the program and see the expected results:liftIO
> evalStateT printState "hello" "hello" > evalStateT printState 3 3
throwError :: MonadError e m => e -> m a #
Is used within a monadic computation to begin exception processing.