diff --git a/src/Data/Reprinting/Errors.hs b/src/Data/Reprinting/Errors.hs index 59a5425e1..c887c5b2d 100644 --- a/src/Data/Reprinting/Errors.hs +++ b/src/Data/Reprinting/Errors.hs @@ -1,10 +1,10 @@ -module Data.Reprinting.Errors ( TranslationException (..) ) where +module Data.Reprinting.Errors ( TranslationError (..) ) where import Data.Reprinting.Token -- | Represents failure occurring in a 'Concrete' machine during the translation -- phases of the reprinting pipeline. -data TranslationException +data TranslationError = UnbalancedPair Context [Context] -- ^ Thrown if an unbalanced 'Enter'/'Exit' pair is encountered. | NoTranslation Element [Context] diff --git a/src/Language/JSON/PrettyPrint.hs b/src/Language/JSON/PrettyPrint.hs index 7751280e1..b908c11fb 100644 --- a/src/Language/JSON/PrettyPrint.hs +++ b/src/Language/JSON/PrettyPrint.hs @@ -17,7 +17,7 @@ import Data.Reprinting.Splice import Data.Reprinting.Token -- | Default printing pipeline for JSON. -defaultJSONPipeline :: (Member (Exc TranslationException) effs) +defaultJSONPipeline :: (Member (Exc TranslationError) effs) => ProcessT (Eff effs) Fragment Splice defaultJSONPipeline = printingJSON @@ -56,7 +56,7 @@ defaultBeautyOpts :: JSONBeautyOpts defaultBeautyOpts = JSONBeautyOpts 2 False -- | Produce JSON with configurable whitespace and layout. -beautifyingJSON :: (Member (Exc TranslationException) effs) +beautifyingJSON :: (Member (Exc TranslationError) effs) => JSONBeautyOpts -> ProcessT (Eff effs) Fragment Splice beautifyingJSON _ = flattened <~ autoT (Kleisli step) where step (Defer el cs) = throwError (NoTranslation el cs) @@ -70,7 +70,7 @@ beautifyingJSON _ = flattened <~ autoT (Kleisli step) where _ -> emit txt -- | Produce whitespace minimal JSON. -minimizingJSON :: (Member (Exc TranslationException) effs) +minimizingJSON :: (Member (Exc TranslationError) effs) => ProcessT (Eff effs) Fragment Splice minimizingJSON = flattened <~ autoT (Kleisli step) where step (Defer el cs) = throwError (NoTranslation el cs) diff --git a/src/Language/Ruby/PrettyPrint.hs b/src/Language/Ruby/PrettyPrint.hs index 4db63e868..c61f64708 100644 --- a/src/Language/Ruby/PrettyPrint.hs +++ b/src/Language/Ruby/PrettyPrint.hs @@ -11,10 +11,10 @@ import Data.Reprinting.Splice import Data.Reprinting.Token as Token -- | Print Ruby syntax. -printingRuby :: (Member (Exc TranslationException) effs) => ProcessT (Eff effs) Fragment Splice +printingRuby :: (Member (Exc TranslationError) effs) => ProcessT (Eff effs) Fragment Splice printingRuby = flattened <~ autoT (Kleisli step) -step :: (Member (Exc TranslationException) effs) => Fragment -> Eff effs (Seq Splice) +step :: (Member (Exc TranslationError) effs) => Fragment -> Eff effs (Seq Splice) step (Verbatim txt) = pure $ emit txt step (New _ _ txt) = pure $ emit txt step (Defer el cs) = case (el, cs) of @@ -53,9 +53,9 @@ step (Defer el cs) = case (el, cs) of endContext times = layout HardWrap <> indent (pred times) -- Example of what writing a plan style machine looks like --- printingRuby' :: (Member (Exc TranslationException) effs) => MachineT (Eff effs) (Is Fragment) Splice +-- printingRuby' :: (Member (Exc TranslationError) effs) => MachineT (Eff effs) (Is Fragment) Splice -- printingRuby' = flattened <~ repeatedly plan where --- plan :: (Member (Exc TranslationException) effs) => PlanT (Is Fragment) (Seq Splice) (Eff effs) () +-- plan :: (Member (Exc TranslationError) effs) => PlanT (Is Fragment) (Seq Splice) (Eff effs) () -- plan = do -- frag <- await -- x <- lift (step frag) diff --git a/src/Reprinting/Pipeline.hs b/src/Reprinting/Pipeline.hs index f2984f4ec..6aa4c1bea 100644 --- a/src/Reprinting/Pipeline.hs +++ b/src/Reprinting/Pipeline.hs @@ -130,7 +130,7 @@ runReprinter :: => Source.Source -> ProcessT Translator Fragment Splice -> Term a (Record fields) - -> Either TranslationException Source.Source + -> Either TranslationError Source.Source runReprinter src translating tree = fmap go . Effect.run @@ -163,7 +163,7 @@ runContextualizing :: ) => Source.Source -> Term a (Record fields) - -> Either TranslationException [Fragment] + -> Either TranslationError [Fragment] runContextualizing src tree = Effect.run . Exc.runError @@ -180,7 +180,7 @@ runTranslating :: => Source.Source -> ProcessT Translator Fragment Splice -> Term a (Record fields) - -> Either TranslationException [Splice] + -> Either TranslationError [Splice] runTranslating src translating tree = Effect.run . Exc.runError diff --git a/src/Reprinting/Translate.hs b/src/Reprinting/Translate.hs index 6faa714df..a1f6aecc3 100644 --- a/src/Reprinting/Translate.hs +++ b/src/Reprinting/Translate.hs @@ -18,13 +18,13 @@ import Data.Reprinting.Token import Data.Reprinting.Errors import qualified Data.Source as Source -type Translator = Eff '[State [Context], Exc TranslationException] +type Translator = Eff '[State [Context], Exc TranslationError] -- | Prepare for language specific translation by contextualizing 'Token's to -- 'Fragment's. contextualizing :: ( Member (State [Context]) effs - , Member (Exc TranslationException) effs + , Member (Exc TranslationError) effs ) => ProcessT (Eff effs) Token Fragment contextualizing = flattened <~ autoT (Kleisli step) where @@ -45,7 +45,7 @@ contextualizing = flattened <~ autoT (Kleisli step) where exitContext :: ( Member (State [Context]) effs - , Member (Exc TranslationException) effs + , Member (Exc TranslationError) effs ) => Context -> Eff effs () exitContext c = do