1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE FlexibleContexts #-}
3module Elm.Compiler (version, parseDependencies, compile, runtimePath) where
5import Control.Monad.Error (MonadError, throwError)
6import qualified Data.List as List
7import qualified Data.Map as Map
8import qualified Text.PrettyPrint as P
10import qualified AST.Module as Module (HeaderAndImports(HeaderAndImports), toInterface)
11import qualified Compile
12import qualified Elm.Compiler.Module as PublicModule
13import qualified Elm.Compiler.Version as Version
14import Elm.Utils ((|>))
15import qualified Elm.Utils as Utils
16import qualified Generate.JavaScript as JS
17import qualified Parse.Helpers as Help
18import qualified Parse.Module as Parse
19import qualified Paths_elm_compiler as Paths
32 :: (MonadError String m)
34 -> m (PublicModule.Name, [PublicModule.Name])
35parseDependencies src =
36 case Help.iParse Parse.headerAndImports src of
40 Right (Module.HeaderAndImports names _exports imports) ->
42 ( PublicModule.Name names
43 , map (PublicModule.Name . fst) imports
49{-| Compiles Elm source code to JavaScript. -}
54 -> Map.Map PublicModule.Name PublicModule.Interface
55 -> Either String (PublicModule.Interface, String)
56compile user packageName source interfaces =
57 let unwrappedInterfaces =
58 Map.mapKeysMonotonic (\(PublicModule.Name name) -> name) interfaces
60 case Compile.compile user packageName unwrappedInterfaces source of
62 Right (Module.toInterface modul, JS.generate modul)
66 |> List.intersperse ""
73{-| Path to the runtime.
75runtimePath :: IO FilePath
77 Utils.getAsset "compiler" Paths.getDataFileName "runtime/core.js"
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