@@ -1,58 +1,50 @@
11{-# OPTIONS_GHC -Wall #-}
22{-# LANGUAGE OverloadedStrings #-}
3−module Elm.Compiler.Imports (defaults) where
3+module Elm.Compiler.Imports
4+ ( Import(..)
5+ , Exposing(..)
6+ , defaults
7+ )
8+ where
49
5−import Data.Text (Text)
610
7−import qualified AST.Exposing as E
8−import qualified AST.Module as Module
9−import qualified Reporting.Annotation as A
10−import qualified Reporting.Region as R
11+import qualified Elm.Name as N
1112
1213
1314
14−-- DEFAULT IMPORTS
15+-- IMPORTS
1516
1617
17−(==>) :: a -> b -> (a,b)
18−(==>) = (,)
18+data Import =
19+ Import
20+ { _name :: N.Name
21+ , _alias :: Maybe N.Name
22+ , _exposing :: Exposing
23+ }
1924
2025
21−defaults :: [Module.DefaultImport]
22−defaults =
23− [ "Basics" ==> Module.ImportMethod Nothing E.Open
24− , "Debug" ==> Module.ImportMethod Nothing E.closed
25− , "List" ==> exposing [E.Lower "::"]
26− , "Maybe" ==> exposing [E.Upper "Maybe" (Just E.Open)]
27− , "Result" ==> exposing [E.Upper "Result" (Just E.Open)]
28− , "String" ==> Module.ImportMethod Nothing E.closed
29− , "Tuple" ==> Module.ImportMethod Nothing E.closed
30− , "Platform" ==> exposing [closedType "Program"]
31− , "Platform.Cmd" ==> named "Cmd" [closedType "Cmd"]
32− , "Platform.Sub" ==> named "Sub" [closedType "Sub"]
33− ]
34−
35−
36−exposing :: [E.Entry] -> Module.ImportMethod
37−exposing entries =
38− Module.ImportMethod Nothing (explicit entries)
39−
26+data Exposing
27+ = Open
28+ | Closed
29+ | TypeOpen N.Name
30+ | TypeClosed N.Name
31+ | Operator N.Name
4032
41−closedType :: Text -> E.Entry
42−closedType name =
43− E.Upper name Nothing
4433
4534
46−named :: Text -> [E.Entry] -> Module.ImportMethod
47−named name entries =
48− Module.ImportMethod (Just name) (explicit entries)
35+-- DEFAULTS
4936
5037
51−explicit :: [E.Entry] -> E.Raw
52−explicit entries =
53− E.Explicit (map (A.A nowhere) entries)
54−
55−
56−nowhere :: R.Region
57−nowhere =
58− R.Region (R.Position 1 1) (R.Position 1 1)
38+defaults :: [Import]
39+defaults =
40+ [ Import "Basics" Nothing Open
41+ , Import "Debug" Nothing Closed
42+ , Import "List" Nothing (Operator "::")
43+ , Import "Maybe" Nothing (TypeOpen "Maybe")
44+ , Import "Result" Nothing (TypeOpen "Result")
45+ , Import "String" Nothing Closed
46+ , Import "Tuple" Nothing Closed
47+ , Import "Platform" Nothing (TypeClosed "Program")
48+ , Import "Platform.Cmd" (Just "Cmd") (TypeClosed "Cmd")
49+ , Import "Platform.Sub" (Just "Sub") (TypeClosed "Sub")
50+ ]