1{-# OPTIONS_GHC -Wall #-}
4 , parseDependencies, compile
5 , Error, errorToString, errorToJson, printError
6 , Warning, warningToString, warningToJson, printWarning
9import qualified Data.Aeson as Json
10import qualified Data.Map as Map
12import qualified AST.Module as Module
13import qualified Compile
14import qualified Elm.Compiler.Module as PublicModule
15import qualified Elm.Compiler.Version as Version
16import qualified Generate.JavaScript as JS
17import qualified Parse.Module as Parse
18import qualified Parse.Parse as Parse
19import qualified Reporting.Annotation as A
20import qualified Reporting.Error as Error
21import qualified Reporting.Result as Result
22import qualified Reporting.Warning as Warning
41 -> Either [Error] (PublicModule.Name, [PublicModule.Name])
42parseDependencies sourceCode =
44 (Result.Result _warnings rawResult) =
45 Parse.parse sourceCode Parse.header
49 Left $ map (Error . A.map Error.Syntax) msgs
51 Result.Ok (Module.Header names _exports imports) ->
53 ( PublicModule.Name names
54 , map (PublicModule.Name . fst . A.drop) imports
60{-| Compiles Elm source code to JavaScript. -}
66 -> Map.Map PublicModule.Name PublicModule.Interface
67 -> ([Warning], Either [Error] (PublicModule.Interface, String))
68compile user packageName isRoot source interfaces =
69 let unwrappedInterfaces =
70 Map.mapKeysMonotonic (\(PublicModule.Name name) -> name) interfaces
72 (Result.Result warnings rawResult) =
73 Compile.compile user packageName isRoot unwrappedInterfaces source
75 (,) (map Warning warnings) $
78 Right (Module.toInterface modul, JS.generate modul)
81 Left (map Error errors)
86newtype Error = Error (A.Located Error.Error)
89errorToString :: String -> String -> Error -> String
90errorToString location source (Error err) =
91 Error.toString location source err
94printError :: String -> String -> Error -> IO ()
95printError location source (Error err) =
96 Error.print location source err
99errorToJson :: String -> Error -> Json.Value
100errorToJson location (Error err) =
101 Error.toJson location err
106newtype Warning = Warning (A.Located Warning.Warning)
109warningToString :: String -> String -> Warning -> String
110warningToString location source (Warning err) =
111 Warning.toString location source err
114printWarning :: String -> String -> Warning -> IO ()
115printWarning location source (Warning err) =
116 Warning.print location source err
119warningToJson :: String -> Warning -> Json.Value
120warningToJson location (Warning err) =
121 Warning.toJson location err
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list