1{- | This module exports functions for compiling Elm to JS.
3module Elm.Internal.Utils (compile, moduleName) where
5import qualified Data.List as List
6import qualified Generate.JavaScript as JS
7import qualified Build.Source as Source
8import qualified Parse.Module as Parser
9import qualified SourceSyntax.Module as M
10import qualified Text.PrettyPrint as P
11import qualified Metadata.Prelude as Prelude
12import System.IO.Unsafe
14-- |This function compiles Elm code to JavaScript. It will return either
15-- an error message or the compiled JS code.
16compile :: String -> Either String String
18 case Source.build False interfaces source of
19 Left docs -> Left . unlines . List.intersperse "" $ map P.render docs
20 Right modul -> Right $ JS.generate modul
22{-# NOINLINE interfaces #-}
23interfaces :: M.Interfaces
24interfaces = unsafePerformIO $ Prelude.interfaces False
26-- |This function extracts the module name of a given source program.
27moduleName :: String -> Maybe String
28moduleName = Parser.getModuleName
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