on master help sign in
Make sure all missing doc comments are reported at once
d77e06dEvan Czaplicki
compiler/src/Elm/Docs.hs+17−25
@@ -18,7 +18,6 @@ module Elm.Docs
18 where
18 where
19
19
20
20
21−import Control.Monad (foldM)
22import qualified Data.ByteString as B
21import qualified Data.ByteString as B
23import qualified Data.List as List
22import qualified Data.List as List
24import Data.Map ((!))
23import Data.Map ((!))
@@ -303,10 +302,9 @@ fromModule (Can.Module name docs exports decls unions aliases binops effects) =
303 Result.mapError Error.Docs $
302 Result.mapError Error.Docs $
304 do checkNames exportDict names
303 do checkNames exportDict names
305 let types = gatherTypes decls Map.empty
304 let types = gatherTypes decls Map.empty
306− foldM
307− (addExport (Info comments types unions aliases binops effects))
305+ let info = Info comments types unions aliases binops effects
308− (emptyModule name overview)
306+ inserters <- Map.traverseWithKey (checkExport info) exportDict
309− (Map.toList exportDict)
307+ return $ foldr ($) (emptyModule name overview) inserters
310
308
311
309
312emptyModule :: ModuleName.Canonical -> B.ByteString -> Module
310emptyModule :: ModuleName.Canonical -> B.ByteString -> Module
@@ -434,51 +432,45 @@ data Info =
434 }
432 }
435
433
436
434
437−addExport :: Info -> Module -> (N.Name, A.Located Can.Export) -> Result i w Module
435+checkExport :: Info -> N.Name -> A.Located Can.Export -> Result i w (Module -> Module)
438−addExport info (Module n c us as_ vs bs) (name, A.At region export) =
436+checkExport info name (A.At region export) =
439 case export of
437 case export of
440 Can.ExportValue ->
438 Can.ExportValue ->
441 do tipe <- getType name info
439 do tipe <- getType name info
442 comment <- getComment region name info
440 comment <- getComment region name info
443−
441+ Result.ok $ \m ->
444− let newValues = Map.insert name (Value comment tipe) vs
442+ m { _values = Map.insert name (Value comment tipe) (_values m) }
445− Result.ok $ Module n c us as_ newValues bs
446
443
447 Can.ExportBinop ->
444 Can.ExportBinop ->
448 do let (Can.Binop_ assoc prec realName) = _iBinops info ! name
445 do let (Can.Binop_ assoc prec realName) = _iBinops info ! name
449 tipe <- getType realName info
446 tipe <- getType realName info
450 comment <- getComment region realName info
447 comment <- getComment region realName info
451−
448+ Result.ok $ \m ->
452− let newBinops = Map.insert name (Binop comment tipe assoc prec) bs
449+ m { _binops = Map.insert name (Binop comment tipe assoc prec) (_binops m) }
453− Result.ok $ Module n c us as_ vs newBinops
454
450
455 Can.ExportAlias ->
451 Can.ExportAlias ->
456 do let (Can.Alias tvars tipe) = _iAliases info ! name
452 do let (Can.Alias tvars tipe) = _iAliases info ! name
457 comment <- getComment region name info
453 comment <- getComment region name info
458−
454+ Result.ok $ \m ->
459− let newAliases = Map.insert name (Alias comment tvars (Extract.fromType tipe)) as_
455+ m { _aliases = Map.insert name (Alias comment tvars (Extract.fromType tipe)) (_aliases m) }
460− Result.ok $ Module n c us newAliases vs bs
461
456
462 Can.ExportUnionOpen ->
457 Can.ExportUnionOpen ->
463 do let (Can.Union tvars ctors _ _) = _iUnions info ! name
458 do let (Can.Union tvars ctors _ _) = _iUnions info ! name
464 comment <- getComment region name info
459 comment <- getComment region name info
465−
460+ Result.ok $ \m ->
466− let newUnions = Map.insert name (Union comment tvars (map dector ctors)) us
461+ m { _unions = Map.insert name (Union comment tvars (map dector ctors)) (_unions m) }
467− Result.ok $ Module n c newUnions as_ vs bs
468
462
469 Can.ExportUnionClosed ->
463 Can.ExportUnionClosed ->
470 do let (Can.Union tvars _ _ _) = _iUnions info ! name
464 do let (Can.Union tvars _ _ _) = _iUnions info ! name
471 comment <- getComment region name info
465 comment <- getComment region name info
472−
466+ Result.ok $ \m ->
473− let newUnions = Map.insert name (Union comment tvars []) us
467+ m { _unions = Map.insert name (Union comment tvars []) (_unions m) }
474− Result.ok $ Module n c newUnions as_ vs bs
475
468
476 Can.ExportPort ->
469 Can.ExportPort ->
477 do tipe <- getType name info
470 do tipe <- getType name info
478 comment <- getComment region name info
471 comment <- getComment region name info
479−
472+ Result.ok $ \m ->
480− let newValues = Map.insert name (Value comment tipe) vs
473+ m { _values = Map.insert name (Value comment tipe) (_values m) }
481− Result.ok $ Module n c us as_ newValues bs
482
474
483
475
484getComment :: R.Region -> N.Name -> Info -> Result i w Comment
476getComment :: R.Region -> N.Name -> Info -> Result i w Comment