oops-examples-0.2.0.0: Oops examples
Safe HaskellSafe-Inferred
LanguageHaskell2010

Examples

Synopsis

Documentation

readIntV1 :: MonadError (Variant e) m => CouldBeF e Text => String -> m Int Source #

A simple function that throws an error.

The type is the one that is inferred by GHC.

readIntV2 :: MonadError (Variant e) m => e `CouldBe` Text => String -> m Int Source #

A simple function that throws an error.

This is the same as before, but we can rewrite constraint on e differently.

readIntV3 :: e `CouldBe` Text => String -> ExceptT (Variant e) Identity Int Source #

A simple function that throws an error.

We can also use ExceptT

readIntV4 :: e `CouldBe` Text => String -> ExceptT (Variant e) IO Int Source #

A simple IO function that throws an error.

We can also use ExceptT of IO.

readIntV5 :: MonadError (Variant e) m => MonadIO m => e `CouldBe` Text => String -> m Int Source #

A simple function that throws an error.

Or use MonadIO instead of IO directly.

readIntV6 :: MonadIO m => e `CouldBe` Text => String -> ExceptT (Variant e) m Int Source #

A simple function that throws an error.

Or use MonadIO with ExceptT.

data NotAnInteger Source #

Constructors

NotAnInteger 

data NotPositive Source #

Constructors

NotPositive 

readPositiveInt1 :: MonadIO m => e `CouldBe` NotAnInteger => e `CouldBe` NotPositive => String -> ExceptT (Variant e) m Int Source #

A simple function can throw two errors

data FileNotFound Source #

Constructors

FileNotFound