git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Remove ParseDesugarError data type

There's no reason to distinguish the individual cases, I think, so this data type just adds noise for no benefit.

commitd09d4302fc6fe6e1750d33d5c3b3256e0c045735 authorHarry Garrood <harry@garrood.me> dateSun 27 Dec 2015, 02:16 (11 years ago) parent6f88b74
4 files changed+14−38
psc-docs/Main.hs+1−7 src/Language/PureScript/Docs/ParseAndDesugar.hs+9−16 src/Language/PureScript/Publish.hs+1−1 src/Language/PureScript/Publish/ErrorsWarnings.hs+3−14
psc-docs/Main.hs+1−7
@@ -70,13 +70,7 @@ docgen (PSCDocsOptions fmt inputGlob output) = do
7070 Markdown -> do
7171 e <- D.parseAndDesugar input [] (\_ ms -> return ms)
7272 case e of
73− Left (D.ParseError err) -> do
74− hPutStrLn stderr $ show err
75− exitFailure
76− Left (D.SortModulesError err) -> do
77− hPutStrLn stderr $ P.prettyPrintMultipleErrors False err
78− exitFailure
79− Left (D.DesugarError err) -> do
73+ Left err -> do
8074 hPutStrLn stderr $ P.prettyPrintMultipleErrors False err
8175 exitFailure
8276 Right ms' ->
src/Language/PureScript/Docs/ParseAndDesugar.hs+9−16
@@ -2,7 +2,6 @@
22
33module Language.PureScript.Docs.ParseAndDesugar
44 ( parseAndDesugar
5− , ParseDesugarError(..)
65 ) where
76
87import Prelude ()
@@ -24,12 +23,6 @@ import qualified Language.PureScript.Constants as C
2423import Language.PureScript.Docs.Types
2524import Language.PureScript.Docs.Convert (collectBookmarks)
2625
27−data ParseDesugarError
28− = ParseError P.MultipleErrors
29− | SortModulesError P.MultipleErrors
30− | DesugarError P.MultipleErrors
31− deriving (Show)
32−
3326-- |
3427-- Given:
3528--
@@ -50,7 +43,7 @@ parseAndDesugar ::
5043 [FilePath]
5144 -> [(PackageName, FilePath)]
5245 -> ([Bookmark] -> [P.Module] -> IO a)
53− -> IO (Either ParseDesugarError a)
46+ -> IO (Either P.MultipleErrors a)
5447parseAndDesugar inputFiles depsFiles callback = do
5548 inputFiles' <- traverse (parseAs Local) inputFiles
5649 depsFiles' <- traverse (\(pkgName, f) -> parseAs (FromDep pkgName) f) depsFiles
@@ -63,15 +56,15 @@ parseAndDesugar inputFiles depsFiles callback = do
6356
6457parseFiles ::
6558 [(FileInfo, FilePath)]
66− -> ExceptT ParseDesugarError IO [(FileInfo, P.Module)]
59+ -> ExceptT P.MultipleErrors IO [(FileInfo, P.Module)]
6760parseFiles =
68− throwLeft ParseError . P.parseModulesFromFiles fileInfoToString
61+ throwLeft . P.parseModulesFromFiles fileInfoToString
6962
7063sortModules ::
7164 [P.Module]
72− -> ExceptT ParseDesugarError IO [P.Module]
65+ -> ExceptT P.MultipleErrors IO [P.Module]
7366sortModules =
74− fmap fst . throwLeft SortModulesError . sortModules' . map importPrim
67+ fmap fst . throwLeft . sortModules' . map importPrim
7568 where
7669 sortModules' :: [P.Module] -> Either P.MultipleErrors ([P.Module], P.ModuleGraph)
7770 sortModules' = P.sortModules
@@ -79,9 +72,9 @@ sortModules =
7972desugarWithBookmarks ::
8073 [(FileInfo, P.Module)]
8174 -> [P.Module]
82− -> ExceptT ParseDesugarError IO ([Bookmark], [P.Module])
75+ -> ExceptT P.MultipleErrors IO ([Bookmark], [P.Module])
8376desugarWithBookmarks msInfo msSorted = do
84− msDesugared <- throwLeft DesugarError (desugar msSorted)
77+ msDesugared <- throwLeft (desugar msSorted)
8578
8679 let msDeps = getDepsModuleNames (map (\(fp, m) -> (,m) <$> fp) msInfo)
8780 msPackages = map (addPackage msDeps) msDesugared
@@ -89,8 +82,8 @@ desugarWithBookmarks msInfo msSorted = do
8982
9083 return (bookmarks, takeLocals msPackages)
9184
92−throwLeft :: (MonadError e m) => (l -> e) -> Either l r -> m r
93−throwLeft f = either (throwError . f) return
85+throwLeft :: (MonadError l m) => Either l r -> m r
86+throwLeft = either throwError return
9487
9588-- | Specifies whether a PureScript source file is considered as:
9689--
src/Language/PureScript/Publish.hs+1−1
@@ -147,7 +147,7 @@ getModulesAndBookmarks :: PrepareM ([D.Bookmark], [D.Module])
147147getModulesAndBookmarks = do
148148 (inputFiles, depsFiles) <- liftIO getInputAndDepsFiles
149149 liftIO (D.parseAndDesugar inputFiles depsFiles renderModules)
150− >>= either (userError . ParseAndDesugarError) return
150+ >>= either (userError . CompileError) return
151151 where
152152 renderModules bookmarks modules =
153153 return (bookmarks, map D.convertModule modules)
src/Language/PureScript/Publish/ErrorsWarnings.hs+3−14
@@ -33,7 +33,6 @@ import Web.Bower.PackageMeta (BowerError, PackageName, runPackageName, showBower
3333import qualified Web.Bower.PackageMeta as Bower
3434
3535import qualified Language.PureScript as P
36−import qualified Language.PureScript.Docs as D
3736
3837import Language.PureScript.Publish.BoxesHelpers
3938
@@ -61,7 +60,7 @@ data UserError
6160 | AmbiguousVersions [Version] -- Invariant: should contain at least two elements
6261 | BadRepositoryField RepositoryFieldError
6362 | MissingDependencies (NonEmpty PackageName)
64− | ParseAndDesugarError D.ParseDesugarError
63+ | CompileError P.MultipleErrors
6564 | DirtyWorkingTree
6665 deriving (Show)
6766
@@ -188,19 +187,9 @@ displayUserError e = case e of
188187 [ "Please install ", them, " first, by running `bower install`."
189188 ])
190189 ]
191− ParseAndDesugarError (D.ParseError err) ->
190+ CompileError err ->
192191 vcat
193− [ para "Parse error:"
194− , indented (P.prettyPrintMultipleErrorsBox False err)
195− ]
196− ParseAndDesugarError (D.SortModulesError err) ->
197− vcat
198− [ para "Error in sortModules:"
199− , indented (P.prettyPrintMultipleErrorsBox False err)
200− ]
201− ParseAndDesugarError (D.DesugarError err) ->
202− vcat
203− [ para "Error while desugaring:"
192+ [ para "Compile error:"
204193 , indented (P.prettyPrintMultipleErrorsBox False err)
205194 ]
206195 DirtyWorkingTree ->