1{-# OPTIONS_GHC -Wall #-}
2{-# LANGUAGE FlexibleContexts #-}
3module Elm.Compiler (version, parseDependencies, compile) where
5import Control.Monad.Error (MonadError, MonadIO, liftIO, 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), Interfaces, toInterface)
11import qualified Build.Source as Source
12import qualified Elm.Compiler.Module as PublicModule
13import qualified Elm.Compiler.Version as Version
14import qualified Generate.JavaScript as JS
15import qualified Metadata.Prelude as Prelude
16import qualified Parse.Helpers as Help
17import qualified Parse.Module as Parse
30 :: (MonadError String m)
32 -> m (PublicModule.Name, [PublicModule.Name])
33parseDependencies src =
34 case Help.iParse Parse.headerAndImports src of
38 Right (Module.HeaderAndImports names _exports imports) ->
40 ( PublicModule.Name names
41 , map (PublicModule.Name . fst) imports
47{-| Compiles Elm source code to JavaScript. -}
50 -> Map.Map PublicModule.Name PublicModule.Interface
51 -> Either String (PublicModule.Interface, String)
52compile source interfaces =
53 case Source.build True unwrappedInterfaces source of
54 Left docs -> Left . unlines . List.intersperse "" $ map P.render docs
55 Right modul -> Right (Module.toInterface modul, JS.generate modul)
58 Map.mapKeysMonotonic (\(PublicModule.Name name) -> name) interfaces
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