on master help sign in
Switch back to stateless API, currently do not want to change this in the next release
1aa3b76Evan Czaplicki
compiler/Language/Elm.hs+10−15
@@ -5,14 +5,7 @@
5 <http://elm-lang.org/Documentation.elm>, and many interactive examples are
5 <http://elm-lang.org/Documentation.elm>, and many interactive examples are
6 available at <http://elm-lang.org/Examples.elm>
6 available at <http://elm-lang.org/Examples.elm>
7-}
7-}
8−module Language.Elm ( compile
8+module Language.Elm (compile, moduleName, runtime, docs) where
9− , interfaces
10− , moduleName
11− , runtime
12− , docs
13− , Interfaces
14− , ModuleInterface )
15−where
16
9
17import qualified Data.List as List
10import qualified Data.List as List
18import qualified Data.Map as Map
11import qualified Data.Map as Map
@@ -25,17 +18,19 @@ import Text.Blaze.Html (Html)
25import qualified Text.PrettyPrint as P
18import qualified Text.PrettyPrint as P
26import qualified Metadata.Prelude as Prelude
19import qualified Metadata.Prelude as Prelude
27import Paths_Elm
20import Paths_Elm
21+import System.IO.Unsafe
28
22
29-- |This function compiles Elm code to JavaScript. It will return either
23-- |This function compiles Elm code to JavaScript. It will return either
30-- an error message or the compiled JS code.
24-- an error message or the compiled JS code.
31−compile :: Interfaces -> String -> Either String String
25+compile :: String -> Either String String
32−compile ifaces source = do
26+compile source =
33− case buildFromSource False ifaces source of
27+ case buildFromSource False interfaces source of
34− Left docs -> Left . unlines . List.intersperse "" $ map P.render docs
28+ Left docs -> Left . unlines . List.intersperse "" $ map P.render docs
35− Right modul -> Right $ jsModule (modul :: MetadataModule () ())
29+ Right modul -> Right $ jsModule (modul :: MetadataModule () ())
36
30
31+{-# NOINLINE interfaces #-}
37−interfaces :: IO Interfaces
32+interfaces :: Interfaces
38−interfaces = Prelude.interfaces
33+interfaces = unsafePerformIO $ Prelude.interfaces
39
34
40-- |This function extracts the module name of a given source program.
35-- |This function extracts the module name of a given source program.
41moduleName :: String -> Maybe String
36moduleName :: String -> Maybe String