@@ -50,6 +50,7 @@ import qualified Parse.Module as Parse
5050import qualified Reporting
5151import qualified Reporting.Annotation as A
5252import qualified Reporting.Error as Error
53+import qualified Reporting.Error.Docs as EDocs
5354import qualified Reporting.Error.Syntax as Syntax
5455import qualified Reporting.Error.Import as Import
5556import qualified Reporting.Exit as Exit
@@ -706,25 +707,30 @@ compile (Env key root projectType _ buildID _ _) docsNeed (Details.Local path ti
706707 in
707708 case Compile.compile pkg ifaces modul of
708709 Right (Compile.Artifacts canonical annotations objects) ->
709− do let name = Src.getName modul
710− let iface = I.fromModule pkg canonical annotations
711− let docs = makeDocs docsNeed canonical
712− let elmi = Stuff.elmi root name
713− File.writeBinary (Stuff.elmo root name) objects
714− maybeOldi <- File.readBinary elmi
715− case maybeOldi of
716− Just oldi | oldi == iface ->
717− do -- iface should be fully forced by equality check
718− Reporting.report key Reporting.BDone
719− let local = Details.Local path time deps main lastChange buildID
720− return (RSame local iface objects docs)
721−
722− _ ->
723− do -- iface may be lazy still
724− File.writeBinary elmi iface
725− Reporting.report key Reporting.BDone
726− let local = Details.Local path time deps main buildID buildID
727− return (RNew local iface objects docs)
710+ case makeDocs docsNeed canonical of
711+ Left err ->
712+ return $ RProblem $
713+ Error.Module (Src.getName modul) path time source (Error.BadDocs err)
714+
715+ Right docs ->
716+ do let name = Src.getName modul
717+ let iface = I.fromModule pkg canonical annotations
718+ let elmi = Stuff.elmi root name
719+ File.writeBinary (Stuff.elmo root name) objects
720+ maybeOldi <- File.readBinary elmi
721+ case maybeOldi of
722+ Just oldi | oldi == iface ->
723+ do -- iface should be fully forced by equality check
724+ Reporting.report key Reporting.BDone
725+ let local = Details.Local path time deps main lastChange buildID
726+ return (RSame local iface objects docs)
727+
728+ _ ->
729+ do -- iface may be lazy still
730+ File.writeBinary elmi iface
731+ Reporting.report key Reporting.BDone
732+ let local = Details.Local path time deps main buildID buildID
733+ return (RNew local iface objects docs)
728734
729735 Left err ->
730736 return $ RProblem $
@@ -825,14 +831,14 @@ toDocsNeed goal =
825831 KeepDocs -> DocsNeed True
826832
827833
828−makeDocs :: DocsNeed -> Can.Module -> Maybe Docs.Module
834+makeDocs :: DocsNeed -> Can.Module -> Either EDocs.Error (Maybe Docs.Module)
829835makeDocs (DocsNeed isNeeded) modul =
830836 if isNeeded then
831837 case Docs.fromModule modul of
832− Right docs -> Just docs
833− Left _ -> Nothing
838+ Right docs -> Right (Just docs)
839+ Left err -> Left err
834840 else
835− Nothing
841+ Right Nothing
836842
837843
838844finalizeDocs :: DocsGoal docs -> Map.Map ModuleName.Raw Result -> IO docs