Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Conformance
Synopsis
- newtype ConformT ue fe w m a = ConformT {
- unConformT :: ReaderT (fe -> m Bool) (WriterT (Notes fe w) (ExceptT (HaltReason ue fe) m)) a
- altConform :: Monad m => ConformT ue fe w m a -> ConformT ue fe w m a -> ConformT ue fe w m a
- data HaltReason ue fe
- data Notes fe w = Notes {
- notesFixableErrors :: ![fe]
- notesWarnings :: ![w]
- nullNotes :: Notes w fe -> Bool
- runConformTFlexible :: (fe -> m Bool) -> ConformT ue fe w m a -> m (Either (HaltReason ue fe) (a, Notes fe w))
- runConformT :: Monad m => ConformT ue fe w m a -> m (Either (HaltReason ue fe) (a, [w]))
- runConformTStrict :: Monad m => ConformT ue fe w m a -> m (Either (Either ue (Notes fe w)) a)
- runConformTLenient :: Monad m => ConformT ue fe w m a -> m (Either ue (a, Notes fe w))
- type Conform ue fe w = ConformT ue fe w Identity
- runConformFlexible :: (fe -> Bool) -> Conform ue fe w a -> Either (HaltReason ue fe) (a, Notes fe w)
- runConform :: Conform ue fe w a -> Either (HaltReason ue fe) (a, [w])
- runConformStrict :: Conform ue fe w a -> Either (Either ue (Notes fe w)) a
- runConformLenient :: Conform ue fe w a -> Either ue (a, Notes fe w)
- tryConform :: Monad m => ConformT ue fe w m a -> ConformT ue fe w m (Maybe a)
- fixAll :: Applicative m => fe -> m Bool
- fixNone :: Applicative m => fe -> m Bool
- conformFromEither :: Monad m => Either ue a -> ConformT ue fe w m a
- conformMapAll :: Monad m => (ue1 -> ue2) -> (fe1 -> fe2) -> (w1 -> w2) -> ConformT ue1 fe1 w1 m a -> ConformT ue2 fe2 w2 m a
- conformMapErrors :: Monad m => (ue1 -> ue2) -> (fe1 -> fe2) -> ConformT ue1 fe1 w m a -> ConformT ue2 fe2 w m a
- conformMapError :: Monad m => (ue1 -> ue2) -> ConformT ue1 fe w m a -> ConformT ue2 fe w m a
- conformMapFixableError :: Monad m => (fe1 -> fe2) -> ConformT ue fe1 w m a -> ConformT ue fe2 w m a
- emitWarning :: Monad m => w -> ConformT ue fe w m ()
- emitFixableError :: Monad m => fe -> ConformT ue fe w m ()
- unfixableError :: Monad m => ue -> ConformT ue fe w m a
Documentation
newtype ConformT ue fe w m a Source #
A conforming monad transformer to compute a result according to a spec.
RFC 2119 describes these terms:
- MUST and MUST NOT: These describe absolute requirements or absolute prohibitions. However, some implementations still do not adhere to these. Some of those situations are fixable, and some are not.
If the situation is fixable, we error with an error of type ue
.
If the situation is fixable, we can either error out (a strict implementation) with an error of type fe
or apply the fix.
The fe
parameter represents fixable errors, which can either be emitted as warnings, or errored on.
A predicate (fe -> Bool)
decides whether to fix the error. (The predicate returns True if the fixable error is to be fixed.)
2. SHOULD and SHOULD NOT:
These describe weaker requirements or prohibitions.
The w
parameter represents warnings to represent cases where requirements or prohibitions were violated.
Constructors
ConformT | |
Fields
|
Instances
Monad m => MonadError (HaltReason ue fe) (ConformT ue fe w m) Source # | |
Defined in Conformance Methods throwError :: HaltReason ue fe -> ConformT ue fe w m a # catchError :: ConformT ue fe w m a -> (HaltReason ue fe -> ConformT ue fe w m a) -> ConformT ue fe w m a # | |
Monad m => MonadReader (fe -> m Bool) (ConformT ue fe w m) Source # | |
Monad m => MonadWriter (Notes fe w) (ConformT ue fe w m) Source # | |
MonadTrans (ConformT ue fe w) Source # | |
Defined in Conformance | |
Monad m => Applicative (ConformT ue fe w m) Source # | |
Defined in Conformance Methods pure :: a -> ConformT ue fe w m a # (<*>) :: ConformT ue fe w m (a -> b) -> ConformT ue fe w m a -> ConformT ue fe w m b # liftA2 :: (a -> b -> c) -> ConformT ue fe w m a -> ConformT ue fe w m b -> ConformT ue fe w m c # (*>) :: ConformT ue fe w m a -> ConformT ue fe w m b -> ConformT ue fe w m b # (<*) :: ConformT ue fe w m a -> ConformT ue fe w m b -> ConformT ue fe w m a # | |
Functor m => Functor (ConformT ue fe w m) Source # | |
Monad m => Monad (ConformT ue fe w m) Source # | |
altConform :: Monad m => ConformT ue fe w m a -> ConformT ue fe w m a -> ConformT ue fe w m a Source #
data HaltReason ue fe Source #
Constructors
HaltedBecauseOfUnfixableError !ue | |
HaltedBecauseOfStrictness !fe |
Instances
(Exception ue, Exception fe) => Exception (HaltReason ue fe) Source # | |
Defined in Conformance Methods toException :: HaltReason ue fe -> SomeException # fromException :: SomeException -> Maybe (HaltReason ue fe) # displayException :: HaltReason ue fe -> String # | |
(Show ue, Show fe) => Show (HaltReason ue fe) Source # | |
Defined in Conformance Methods showsPrec :: Int -> HaltReason ue fe -> ShowS # show :: HaltReason ue fe -> String # showList :: [HaltReason ue fe] -> ShowS # | |
(Eq ue, Eq fe) => Eq (HaltReason ue fe) Source # | |
Defined in Conformance Methods (==) :: HaltReason ue fe -> HaltReason ue fe -> Bool # (/=) :: HaltReason ue fe -> HaltReason ue fe -> Bool # | |
Monad m => MonadError (HaltReason ue fe) (ConformT ue fe w m) Source # | |
Defined in Conformance Methods throwError :: HaltReason ue fe -> ConformT ue fe w m a # catchError :: ConformT ue fe w m a -> (HaltReason ue fe -> ConformT ue fe w m a) -> ConformT ue fe w m a # |
Constructors
Notes | |
Fields
|
runConformTFlexible :: (fe -> m Bool) -> ConformT ue fe w m a -> m (Either (HaltReason ue fe) (a, Notes fe w)) Source #
Most flexible way to run a ConformT
runConformT :: Monad m => ConformT ue fe w m a -> m (Either (HaltReason ue fe) (a, [w])) Source #
Don't fix any fixable errors.
This is standard-compliant.
runConformTStrict :: Monad m => ConformT ue fe w m a -> m (Either (Either ue (Notes fe w)) a) Source #
Don't fix any fixable errors, and don't allow any warnings either
This is standard-compliant, but potentially more strict than necessary.
runConformTLenient :: Monad m => ConformT ue fe w m a -> m (Either ue (a, Notes fe w)) Source #
Fix as much as possible
That this is not standard-compliant.
Arguments
:: (fe -> Bool) | Predicate to select fixable errors that should be fixed and thereby become a warning instead. |
-> Conform ue fe w a | |
-> Either (HaltReason ue fe) (a, Notes fe w) |
Most flexible way to run a Conform
runConform :: Conform ue fe w a -> Either (HaltReason ue fe) (a, [w]) Source #
Don't fix any fixable errors.
This is standard-compliant
runConformStrict :: Conform ue fe w a -> Either (Either ue (Notes fe w)) a Source #
Don't fix any fixable errors, and don't allow any warnings either
This is standard-compliant, but potentially more strict than necessary.
runConformLenient :: Conform ue fe w a -> Either ue (a, Notes fe w) Source #
Fix as much as possible
That this is not standard-compliant.
tryConform :: Monad m => ConformT ue fe w m a -> ConformT ue fe w m (Maybe a) Source #
Try to run a conform function, return Nothing if there were unfixable errors or unfixed fixable errors.
fixAll :: Applicative m => fe -> m Bool Source #
fixNone :: Applicative m => fe -> m Bool Source #
conformMapAll :: Monad m => (ue1 -> ue2) -> (fe1 -> fe2) -> (w1 -> w2) -> ConformT ue1 fe1 w1 m a -> ConformT ue2 fe2 w2 m a Source #
conformMapErrors :: Monad m => (ue1 -> ue2) -> (fe1 -> fe2) -> ConformT ue1 fe1 w m a -> ConformT ue2 fe2 w m a Source #
conformMapError :: Monad m => (ue1 -> ue2) -> ConformT ue1 fe w m a -> ConformT ue2 fe w m a Source #
conformMapFixableError :: Monad m => (fe1 -> fe2) -> ConformT ue fe1 w m a -> ConformT ue fe2 w m a Source #
emitWarning :: Monad m => w -> ConformT ue fe w m () Source #
emitFixableError :: Monad m => fe -> ConformT ue fe w m () Source #
unfixableError :: Monad m => ue -> ConformT ue fe w m a Source #