on master help sign in
Make sure all missing doc comments are reported at once
commitd77e06d5a761ef42e46e020d06654a1a2f819822 authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 7 May 2018, 18:05 (8 years ago) parent3aa4190
1 file changed+17−25
compiler/src/Elm/Docs.hs+17−25
compiler/src/Elm/Docs.hs+17−25
@@ -18,7 +18,6 @@ module Elm.Docs
1818 where
1919
2020
21−import Control.Monad (foldM)
2221import qualified Data.ByteString as B
2322import qualified Data.List as List
2423import Data.Map ((!))
@@ -303,10 +302,9 @@ fromModule (Can.Module name docs exports decls unions aliases binops effects) =
303302 Result.mapError Error.Docs $
304303 do checkNames exportDict names
305304 let types = gatherTypes decls Map.empty
306− foldM
307− (addExport (Info comments types unions aliases binops effects))
308− (emptyModule name overview)
309− (Map.toList exportDict)
305+ let info = Info comments types unions aliases binops effects
306+ inserters <- Map.traverseWithKey (checkExport info) exportDict
307+ return $ foldr ($) (emptyModule name overview) inserters
310308
311309
312310emptyModule :: ModuleName.Canonical -> B.ByteString -> Module
@@ -434,51 +432,45 @@ data Info =
434432 }
435433
436434
437−addExport :: Info -> Module -> (N.Name, A.Located Can.Export) -> Result i w Module
438−addExport info (Module n c us as_ vs bs) (name, A.At region export) =
435+checkExport :: Info -> N.Name -> A.Located Can.Export -> Result i w (Module -> Module)
436+checkExport info name (A.At region export) =
439437 case export of
440438 Can.ExportValue ->
441439 do tipe <- getType name info
442440 comment <- getComment region name info
443−
444− let newValues = Map.insert name (Value comment tipe) vs
445− Result.ok $ Module n c us as_ newValues bs
441+ Result.ok $ \m ->
442+ m { _values = Map.insert name (Value comment tipe) (_values m) }
446443
447444 Can.ExportBinop ->
448445 do let (Can.Binop_ assoc prec realName) = _iBinops info ! name
449446 tipe <- getType realName info
450447 comment <- getComment region realName info
451−
452− let newBinops = Map.insert name (Binop comment tipe assoc prec) bs
453− Result.ok $ Module n c us as_ vs newBinops
448+ Result.ok $ \m ->
449+ m { _binops = Map.insert name (Binop comment tipe assoc prec) (_binops m) }
454450
455451 Can.ExportAlias ->
456452 do let (Can.Alias tvars tipe) = _iAliases info ! name
457453 comment <- getComment region name info
458−
459− let newAliases = Map.insert name (Alias comment tvars (Extract.fromType tipe)) as_
460− Result.ok $ Module n c us newAliases vs bs
454+ Result.ok $ \m ->
455+ m { _aliases = Map.insert name (Alias comment tvars (Extract.fromType tipe)) (_aliases m) }
461456
462457 Can.ExportUnionOpen ->
463458 do let (Can.Union tvars ctors _ _) = _iUnions info ! name
464459 comment <- getComment region name info
465−
466− let newUnions = Map.insert name (Union comment tvars (map dector ctors)) us
467− Result.ok $ Module n c newUnions as_ vs bs
460+ Result.ok $ \m ->
461+ m { _unions = Map.insert name (Union comment tvars (map dector ctors)) (_unions m) }
468462
469463 Can.ExportUnionClosed ->
470464 do let (Can.Union tvars _ _ _) = _iUnions info ! name
471465 comment <- getComment region name info
472−
473− let newUnions = Map.insert name (Union comment tvars []) us
474− Result.ok $ Module n c newUnions as_ vs bs
466+ Result.ok $ \m ->
467+ m { _unions = Map.insert name (Union comment tvars []) (_unions m) }
475468
476469 Can.ExportPort ->
477470 do tipe <- getType name info
478471 comment <- getComment region name info
479−
480− let newValues = Map.insert name (Value comment tipe) vs
481− Result.ok $ Module n c us as_ newValues bs
472+ Result.ok $ \m ->
473+ m { _values = Map.insert name (Value comment tipe) (_values m) }
482474
483475
484476getComment :: R.Region -> N.Name -> Info -> Result i w Comment