@@ -5,14 +5,7 @@
55 <http://elm-lang.org/Documentation.elm>, and many interactive examples are
66 available at <http://elm-lang.org/Examples.elm>
77-}
8−module Language.Elm ( compile
9− , interfaces
10− , moduleName
11− , runtime
12− , docs
13− , Interfaces
14− , ModuleInterface )
15−where
8+module Language.Elm (compile, moduleName, runtime, docs) where
169
1710import qualified Data.List as List
1811import qualified Data.Map as Map
@@ -25,17 +18,19 @@ import Text.Blaze.Html (Html)
2518import qualified Text.PrettyPrint as P
2619import qualified Metadata.Prelude as Prelude
2720import Paths_Elm
21+import System.IO.Unsafe
2822
2923-- |This function compiles Elm code to JavaScript. It will return either
3024-- an error message or the compiled JS code.
31−compile :: Interfaces -> String -> Either String String
32−compile ifaces source = do
33− case buildFromSource False ifaces source of
34− Left docs -> Left . unlines . List.intersperse "" $ map P.render docs
35− Right modul -> Right $ jsModule (modul :: MetadataModule () ())
25+compile :: String -> Either String String
26+compile source =
27+ case buildFromSource False interfaces source of
28+ Left docs -> Left . unlines . List.intersperse "" $ map P.render docs
29+ Right modul -> Right $ jsModule (modul :: MetadataModule () ())
3630
37−interfaces :: IO Interfaces
38−interfaces = Prelude.interfaces
31+{-# NOINLINE interfaces #-}
32+interfaces :: Interfaces
33+interfaces = unsafePerformIO $ Prelude.interfaces
3934
4035-- |This function extracts the module name of a given source program.
4136moduleName :: String -> Maybe String