@@ -10,8 +10,6 @@ module Elm.Outline
12 , defaultSummary
12 , defaultSummary
15 , flattenExposed
13 , flattenExposed
@@ -34,7 +32,6 @@ import qualified Elm.Version as V
34import qualified Json.Decode as D
32import qualified Json.Decode as D
35import qualified Json.Encode as E
33import qualified Json.Encode as E
36import qualified Reporting.Exit as Exit
34import qualified Reporting.Exit as Exit
37−import qualified Reporting.Exit.Assets as E
@@ -85,28 +82,7 @@ defaultSummary =
88−-- QUERIES
85+-- HELPERS
91−isPlatformPackage :: Outline -> Bool
92−isPlatformPackage outline =
98− let author = Pkg._author (_pkg_name pkgOutline) in
99− author == "elm" || author == "elm-explorations"
102−getName :: Outline -> Pkg.Name
108− Pkg (PkgOutline name _ _ _ _ _ _ _) ->
112flattenExposed :: Exposed -> [ModuleName.Raw]
88flattenExposed :: Exposed -> [ModuleName.Raw]
@@ -195,12 +171,12 @@ encodeDeps encodeValue deps =
195-- PARSE AND VERIFY
171-- PARSE AND VERIFY
198−read :: FilePath -> IO (Either Exit.OutlineProblem Outline)
174+read :: FilePath -> IO (Either Exit.Outline Outline)
199read root =
175read root =
200 do result <- D.fromFile decoder (root </> "elm.json")
176 do result <- D.fromFile decoder (root </> "elm.json")
201 case result of
177 case result of
202 Left err ->
178 Left err ->
203− return $ Left (Exit.BadOutlineStructure err)
179+ return $ Left (Exit.OutlineHasBadStructure err)
205 Right outline ->
181 Right outline ->
206 case outline of
182 case outline of
@@ -211,7 +187,7 @@ read root =
211 do badDirs <- filterM (isBadSrcDir root) srcDirs
187 do badDirs <- filterM (isBadSrcDir root) srcDirs
212 case badDirs of
188 case badDirs of
213 [] -> return $ Right outline
189 [] -> return $ Right outline
214− d:ds -> return $ Left (Exit.BadOutlineSrcDirs d ds)
190+ d:ds -> return $ Left (Exit.OutlineHasBadSrcDirs d ds)
217isBadSrcDir :: FilePath -> FilePath -> IO Bool
193isBadSrcDir :: FilePath -> FilePath -> IO Bool
@@ -224,7 +200,7 @@ isBadSrcDir root dir =
226type Decoder a =
202type Decoder a =
227− D.Decoder E.BadElmJsonContent a
203+ D.Decoder Exit.OutlineProblem a
230decoder :: Decoder Outline
206decoder :: Decoder Outline
@@ -238,7 +214,7 @@ decoder =
238 Pkg <$> pkgDecoder
214 Pkg <$> pkgDecoder
241− D.failure (E.BadType other)
217+ D.failure (Exit.OP_BadType other)
244appDecoder :: Decoder AppOutline
220appDecoder :: Decoder AppOutline
@@ -255,9 +231,9 @@ appDecoder =
255pkgDecoder :: Decoder PkgOutline
231pkgDecoder :: Decoder PkgOutline
256pkgDecoder =
232pkgDecoder =
257 PkgOutline
233 PkgOutline
258− <$> D.field "name" (D.mapError E.BadPkgName Pkg.decoder)
234+ <$> D.field "name" (D.mapError Exit.OP_BadPkgName Pkg.decoder)
259 <*> D.field "summary" summaryDecoder
235 <*> D.field "summary" summaryDecoder
260− <*> D.field "license" (Licenses.decoder E.BadLicense)
236+ <*> D.field "license" (Licenses.decoder Exit.OP_BadLicense)
261 <*> D.field "version" versionDecoder
237 <*> D.field "version" versionDecoder
262 <*> D.field "exposed-modules" exposedDecoder
238 <*> D.field "exposed-modules" exposedDecoder
263 <*> D.field "dependencies" (depsDecoder constraintDecoder)
239 <*> D.field "dependencies" (depsDecoder constraintDecoder)
@@ -274,17 +250,17 @@ summaryDecoder =
274 do summary <- D.string
250 do summary <- D.string
275 if Utf8.size summary < 80
251 if Utf8.size summary < 80
276 then return summary
252 then return summary
277− else D.failure E.BadSummaryTooLong
253+ else D.failure Exit.OP_BadSummaryTooLong
280versionDecoder :: Decoder V.Version
256versionDecoder :: Decoder V.Version
281versionDecoder =
257versionDecoder =
282− D.mapError E.BadVersion V.decoder
258+ D.mapError Exit.OP_BadVersion V.decoder
285constraintDecoder :: Decoder Con.Constraint
261constraintDecoder :: Decoder Con.Constraint
286constraintDecoder =
262constraintDecoder =
287− D.mapError E.BadConstraint Con.decoder
263+ D.mapError Exit.OP_BadConstraint Con.decoder
290depsDecoder :: Decoder a -> Decoder (Map.Map Pkg.Name a)
266depsDecoder :: Decoder a -> Decoder (Map.Map Pkg.Name a)
@@ -301,7 +277,7 @@ validateKey (key, value) =
301 return (name, value)
277 return (name, value)
303 Left _ ->
279 Left _ ->
304− D.failure (E.BadDependencyName key)
280+ D.failure (Exit.OP_BadDependencyName key)
307dirDecoder :: Decoder FilePath
283dirDecoder :: Decoder FilePath
@@ -325,14 +301,14 @@ exposedDecoder =
326moduleDecoder :: Decoder ModuleName.Raw
302moduleDecoder :: Decoder ModuleName.Raw
327moduleDecoder =
303moduleDecoder =
328− D.mapError E.BadModuleName ModuleName.decoder
304+ D.mapError Exit.OP_BadModuleName ModuleName.decoder
331checkHeader :: Utf8.String -> Decoder ()
307checkHeader :: Utf8.String -> Decoder ()
332checkHeader header =
308checkHeader header =
333 if Utf8.size header < 20
309 if Utf8.size header < 20
334 then return ()
310 then return ()
335− else D.failure (E.BadModuleHeaderTooLong header)
311+ else D.failure (Exit.OP_BadModuleHeaderTooLong header)