on master help sign in
Remove some Docs/ stuff that's not necessary anymore
f1e29e9Evan Czaplicki
src/Docs/AST.hsdeleted−79
@@ -1,79 +0,0 @@
1−{-# OPTIONS_GHC -Wall #-}
2−module Docs.AST
3− ( Docs(..), Centralized, Checked
4− , Entry(..), Raw, Good
5− , Union(..)
6− , Alias(..)
7− , Value(..), RawValue, GoodValue
8− )
9− where
10−
11−
12−import qualified Data.Map as Map
13−import Data.Text (Text)
14−
15−import qualified AST.Declaration as Decl
16−import qualified Elm.Compiler.Type as Type
17−import qualified Reporting.Annotation as A
18−
19−
20−
21−-- DOCS
22−
23−
24−data Docs unions aliases values =
25− Docs
26− { _overview :: Text
27− , _unions :: Map.Map Text unions
28− , _aliases :: Map.Map Text aliases
29− , _values :: Map.Map Text values
30− }
31−
32−
33−type Centralized =
34− Docs (Raw Union) (Raw Alias) (Raw RawValue)
35−
36−
37−type Checked =
38− Docs (Good Union) (Good Alias) (Good GoodValue)
39−
40−
41−
42−-- ENTRY
43−
44−
45−data Entry comment details =
46− Entry
47− { _comment :: !comment
48− , _details :: !details
49− }
50−
51−
52−type Raw a =
53− A.Located (Entry (Maybe Text) a)
54−
55−
56−type Good a =
57− Entry Text a
58−
59−
60−
61−-- INFO
62−
63−
64−data Alias =
65− Alias [Text] Type.Type
66−
67−
68−data Union =
69− Union [Text] [(Text, [Type.Type])]
70−
71−
72−data Value tipe
73− = Value tipe
74− | Infix tipe Decl.Assoc Int
75−
76−
77−type RawValue = Value (Maybe Type.Type)
78−
79−type GoodValue = Value Type.Type
src/Docs/Centralize.hsdeleted−100
@@ -1,100 +0,0 @@
1−module Docs.Centralize (centralize) where
2−
3−import Control.Arrow (second)
4−import qualified Data.Map as Map
5−import qualified Data.Maybe as Maybe
6−import Data.Text (Text)
7−
8−import qualified AST.Declaration as Decl
9−import qualified AST.Expression.Canonical as Canonical
10−import qualified AST.Helpers as Help
11−import qualified AST.Pattern as Pattern
12−import qualified AST.Type as Type
13−import qualified Docs.AST as Docs
14−import qualified Elm.Compiler.Type.Extract as Extract
15−import qualified Reporting.Annotation as A
16−import qualified Reporting.Region as R
17−
18−
19−
20−-- CENTRALIZE
21−
22−
23−centralize :: Decl.Canonical -> Text -> Docs.Centralized
24−centralize (Decl.Decls defs unions aliases infixes) overview =
25− let
26− infixDict =
27− Map.fromList (map toInfixPair infixes)
28− in
29− Docs.Docs
30− overview
31− (Map.fromList (map unionToEntry unions))
32− (Map.fromList (map aliasToEntry aliases))
33− (Map.fromList (Maybe.mapMaybe (defToEntry infixDict) defs))
34−
35−
36−
37−-- ENTRY
38−
39−
40−type Entry a =
41− (Text, Docs.Raw a)
42−
43−
44−makeEntry :: Text -> (R.Region, Maybe Text) -> details -> Entry details
45−makeEntry name (region, maybeComment) details =
46− ( name, A.A region (Docs.Entry maybeComment details) )
47−
48−
49−
50−-- UNIONS
51−
52−
53−unionToEntry :: A.Commented (Decl.Union Type.Canonical) -> Entry Docs.Union
54−unionToEntry (A.A ann (Decl.Type name args ctors)) =
55− makeEntry name ann $ Docs.Union args $
56− map (second (map Extract.extract)) ctors
57−
58−
59−
60−-- ALIASES
61−
62−
63−aliasToEntry :: A.Commented (Decl.Alias Type.Canonical) -> Entry Docs.Alias
64−aliasToEntry (A.A ann (Decl.Type name args tipe)) =
65− makeEntry name ann $ Docs.Alias args $ Extract.extract tipe
66−
67−
68−
69−-- VALUES
70−
71−
72−defToEntry :: Map.Map Text (Decl.Assoc, Int) -> A.Commented Canonical.Def -> Maybe (Entry Docs.RawValue)
73−defToEntry infixDict (A.A (_, maybeComment) definition) =
74− let
75− (Canonical.Def _ (A.A region pattern) _ maybeType) =
76− definition
77−
78− tipe =
79− fmap (Extract.extract . A.drop) maybeType
80− in
81− case pattern of
82− Pattern.Var name ->
83− Just $ makeEntry name (region, maybeComment) $
84− case Map.lookup name infixDict of
85− Just (assoc, prec) ->
86− Docs.Infix tipe assoc prec
87−
88− Nothing ->
89− if Help.isOp name then
90− Docs.Infix tipe Decl.defaultAssociativity Decl.defaultPrecedence
91− else
92− Docs.Value tipe
93−
94− _ ->
95− Nothing
96−
97−
98−toInfixPair :: Decl.Infix -> ( Text, (Decl.Assoc, Int) )
99−toInfixPair (Decl.Infix name assoc precedence) =
100− ( name, (assoc, precedence) )