tus = nHide $ IUniv UShared
tf = nHide IFree
- cqPlans = map (\(fa,r,e) -> (fa,r,check e)) qPlans
+ cqPlans = map check qPlans
where
- check (Right p) = p
- check (Left _) = dynacPanic $ "Backchaining planner failed"
+ check (f,r,Right p) = (f,r,p)
+ check (_,r,Left _) = dynacUserErr $
+ "Unable to plan backchaining for rule"
+ <//> (prettySpanLoc (r_span r))
+ <> dot
in do
-- Do this before forcing cInitializers, cuPlans, etc.,
parse aggs = do
pr <- T.parseFromFileEx (P.oneshotDynaParser aggs <* T.eof) fileName
case pr of
- TR.Failure td -> dynacUserANSIErr $ PPA.align ("Parser error" PPA.<$> td)
+ TR.Failure td -> dynacParseErr $ PPA.align td
TR.Success rs -> return rs
printerr x = pe x >> exitFailure
pe (UserProgramError d) = do
- PP.hPutDoc stderr (upeMsg <> line <> PP.indent 1 d)
+ PP.hPutDoc stderr (upeMsg <> line <> PP.indent 1 d <//> upePostfix)
hPutStrLn stderr ""
- pe (UserProgramANSIError d) = do
- PPA.hPutDoc stderr (upeMsg <> PPA.line <> PPA.indent 1 d)
+ pe (UserProgramParseError d) = do
+ PPA.hPutDoc stderr (parseMsg <> PPA.line <> PPA.indent 1 d)
hPutStrLn stderr ""
pe (InvocationError d) = do
PP.hPutDoc stderr ("Invocation error:" <> line <> PP.indent 1 d)
hPutStrLn stderr ""
upeMsg :: (IsString s) => s
- upeMsg = "FATAL: Encountered error in input program:"
+ upeMsg = "Encountered error in input program:"
+
+ upePostfix :: Doc e
+ upePostfix = "Everything was syntactically valid, but we could not"
+ <//> "see it through."
+
+ parseMsg = "Could not parse:"
sorryMsg :: (IsString s) => s
sorryMsg = "Terribly sorry, but you've hit an unsupported feature"
-- | The user program contains an error
UserProgramError (PP.Doc TP.Effect)
- -- | Same as 'UserProgramError' but with ANSI documentation
- | UserProgramANSIError PPA.Doc
+ -- | Parser errors get their own branch for convenience of printout
+ | UserProgramParseError PPA.Doc
-- | Something went wrong when trying to understand arguments
| InvocationError (PP.Doc TP.Effect)
-- | Throw an ANSI error; this is used inside the parser, primarily, due to
-- trifecta's movement to the ANSI prettyprinter.
-dynacUserANSIErr :: PPA.Doc -> a
-dynacUserANSIErr = throw . UserProgramANSIError
+dynacParseErr :: PPA.Doc -> a
+dynacParseErr = throw . UserProgramParseError
-- | A type-restricted version of 'throw'
dynacThrow :: DynacException -> a
:- :- =============
a := 1
:- DynaCompilerError:
-FATAL: Encountered error in input program:
- Conflicting aggregators; rule /home/timv/.dyna/tmp/966093dc38b755a6f17b02774b5c656931163a3a.dyna:5:1-/home/timv/.dyna/tmp/966093dc38b755a6f17b02774b5c656931163a3a.dyna:5:3
+Encountered error in input program:
+ Conflicting aggregators; rule /home/timv/.dyna/tmp/31141/966093dc38b755a6f17b02774b5c656931163a3a.dyna:5:1-/home/timv/.dyna/tmp/31141/966093dc38b755a6f17b02774b5c656931163a3a.dyna:5:3
uses '|=' for a/0 but I had been lead to expect '+='.
+Everything was syntactically valid, but we could not
+see it through.
> new rule(s) were not added to program.