module DDC.Core.Flow.Transform.Rates.Fail
( Fail (..)
, LogFailures
, warn, run)
where
import DDC.Core.Flow.Prim
import DDC.Base.Pretty
import Control.Monad.Writer
import Data.List
data Fail
= FailNotANormalForm
| FailNamesNotUnique
| FailNoDeBruijnAllowed
| FailRecursiveBindings
| FailLetRegionNotHandled
| FailConstraintFilteredLessFiltered Name Name
| FailConstraintFilteredNotUnique Name Name
deriving (Show, Eq)
instance Pretty Fail where
ppr fails = text (show fails)
type LogFailures a = Writer [Fail] a
warn :: Fail -> LogFailures ()
warn w = tell [w]
run :: LogFailures a -> (a, [Fail])
run comp
= case runWriter comp of
(a, warns) -> (a, nub warns)