@@ -10,8 +10,6 @@ module Elm.Outline
1010 , encode
1111 , decoder
1212 , defaultSummary
13− , isPlatformPackage
14− , getName
1513 , flattenExposed
1614 )
1715 where
@@ -34,7 +32,6 @@ import qualified Elm.Version as V
3432import qualified Json.Decode as D
3533import qualified Json.Encode as E
3634import qualified Reporting.Exit as Exit
37−import qualified Reporting.Exit.Assets as E
3835
3936
4037
@@ -85,28 +82,7 @@ defaultSummary =
8582
8683
8784
88−-- QUERIES
89−
90−
91−isPlatformPackage :: Outline -> Bool
92−isPlatformPackage outline =
93− case outline of
94− App _ ->
95− False
96−
97− Pkg pkgOutline ->
98− let author = Pkg._author (_pkg_name pkgOutline) in
99− author == "elm" || author == "elm-explorations"
100−
101−
102−getName :: Outline -> Pkg.Name
103−getName outline =
104− case outline of
105− App _ ->
106− Pkg.dummyName
107−
108− Pkg (PkgOutline name _ _ _ _ _ _ _) ->
109− name
85+-- HELPERS
11086
11187
11288flattenExposed :: Exposed -> [ModuleName.Raw]
@@ -195,12 +171,12 @@ encodeDeps encodeValue deps =
195171-- PARSE AND VERIFY
196172
197173
198−read :: FilePath -> IO (Either Exit.OutlineProblem Outline)
174+read :: FilePath -> IO (Either Exit.Outline Outline)
199175read root =
200176 do result <- D.fromFile decoder (root </> "elm.json")
201177 case result of
202178 Left err ->
203− return $ Left (Exit.BadOutlineStructure err)
179+ return $ Left (Exit.OutlineHasBadStructure err)
204180
205181 Right outline ->
206182 case outline of
@@ -211,7 +187,7 @@ read root =
211187 do badDirs <- filterM (isBadSrcDir root) srcDirs
212188 case badDirs of
213189 [] -> return $ Right outline
214− d:ds -> return $ Left (Exit.BadOutlineSrcDirs d ds)
190+ d:ds -> return $ Left (Exit.OutlineHasBadSrcDirs d ds)
215191
216192
217193isBadSrcDir :: FilePath -> FilePath -> IO Bool
@@ -224,7 +200,7 @@ isBadSrcDir root dir =
224200
225201
226202type Decoder a =
227− D.Decoder E.BadElmJsonContent a
203+ D.Decoder Exit.OutlineProblem a
228204
229205
230206decoder :: Decoder Outline
@@ -238,7 +214,7 @@ decoder =
238214 Pkg <$> pkgDecoder
239215
240216 other ->
241− D.failure (E.BadType other)
217+ D.failure (Exit.OP_BadType other)
242218
243219
244220appDecoder :: Decoder AppOutline
@@ -255,9 +231,9 @@ appDecoder =
255231pkgDecoder :: Decoder PkgOutline
256232pkgDecoder =
257233 PkgOutline
258− <$> D.field "name" (D.mapError E.BadPkgName Pkg.decoder)
234+ <$> D.field "name" (D.mapError Exit.OP_BadPkgName Pkg.decoder)
259235 <*> D.field "summary" summaryDecoder
260− <*> D.field "license" (Licenses.decoder E.BadLicense)
236+ <*> D.field "license" (Licenses.decoder Exit.OP_BadLicense)
261237 <*> D.field "version" versionDecoder
262238 <*> D.field "exposed-modules" exposedDecoder
263239 <*> D.field "dependencies" (depsDecoder constraintDecoder)
@@ -274,17 +250,17 @@ summaryDecoder =
274250 do summary <- D.string
275251 if Utf8.size summary < 80
276252 then return summary
277− else D.failure E.BadSummaryTooLong
253+ else D.failure Exit.OP_BadSummaryTooLong
278254
279255
280256versionDecoder :: Decoder V.Version
281257versionDecoder =
282− D.mapError E.BadVersion V.decoder
258+ D.mapError Exit.OP_BadVersion V.decoder
283259
284260
285261constraintDecoder :: Decoder Con.Constraint
286262constraintDecoder =
287− D.mapError E.BadConstraint Con.decoder
263+ D.mapError Exit.OP_BadConstraint Con.decoder
288264
289265
290266depsDecoder :: Decoder a -> Decoder (Map.Map Pkg.Name a)
@@ -301,7 +277,7 @@ validateKey (key, value) =
301277 return (name, value)
302278
303279 Left _ ->
304− D.failure (E.BadDependencyName key)
280+ D.failure (Exit.OP_BadDependencyName key)
305281
306282
307283dirDecoder :: Decoder FilePath
@@ -325,14 +301,14 @@ exposedDecoder =
325301
326302moduleDecoder :: Decoder ModuleName.Raw
327303moduleDecoder =
328− D.mapError E.BadModuleName ModuleName.decoder
304+ D.mapError Exit.OP_BadModuleName ModuleName.decoder
329305
330306
331307checkHeader :: Utf8.String -> Decoder ()
332308checkHeader header =
333309 if Utf8.size header < 20
334310 then return ()
335− else D.failure (E.BadModuleHeaderTooLong header)
311+ else D.failure (Exit.OP_BadModuleHeaderTooLong header)
336312
337313
338314