diff --git a/Elm.cabal b/Elm.cabal index 4dad647..cc5bd72 100644 --- a/Elm.cabal +++ b/Elm.cabal @@ -1,6 +1,6 @@ Name: Elm -Version: 0.1.0 +Version: 0.1.1.2 Synopsis: The Elm compiler and server. Description: Elm aims to make client-side web-development more pleasant. It is a statically/strongly typed, functional reactive @@ -16,7 +16,7 @@ Author: Evan Czaplicki Maintainer: info@elm-lang.org Copyright: Copyright: (c) 2011-2012 Evan Czaplicki -Category: Compiler +Category: Compiler, Language Build-type: Simple @@ -29,12 +29,12 @@ source-repository head Executable elm -- .hs or .lhs file containing the Main module. - Main-is: Elm.hs - Hs-Source-Dirs: src, src/Parse, src/Types - other-modules: Ast, CompileToJS, FreeVar, GenerateHtml, Initialize, - Rename, Replace, ToHtml, Binop, Combinators, Lexer, + Main-is: Compiler.hs + Hs-Source-Dirs: src, src/Parse, src/Types, src/Language + other-modules: Ast, CompileToJS, GenerateHtml, Guid, Initialize, + Rename, Language.Elm, Binop, Combinators, Lexer, ParsePatterns, Parser, ParserLib, ParseTypes, Tokens, - Types + Types, Constrain, Hints, Types, Unify -- Packages needed in order to build this package. ghc-options: -O3 -rtsopts -auto-all -caf-all @@ -52,11 +52,19 @@ Executable elm Executable elm-server Main-is: Server.hs Hs-Source-Dirs: src, src/Parse, src/Types - other-modules: Ast, CompileToJS, FreeVar, GenerateHtml, Initialize, - Rename, Replace, ToHtml, Binop, Combinators, Lexer, + other-modules: Ast, CompileToJS, GenerateHtml, Guid, Initialize, + Rename, Language.Elm, Binop, Combinators, Lexer, ParsePatterns, Parser, ParserLib, ParseTypes, Tokens, - Types + Types, Constrain, Hints, Types, Unify ghc-options: -O3 -rtsopts -auto-all -caf-all Build-depends: base >=4.2 && <5, containers >= 0.3, transformers >= 0.2, mtl >= 2, parsec >= 3.1.1, blaze-html == 0.5.0.*, HTTP >= 4000, happstack-server == 7.0.2 + +Library + exposed-modules: Language.Elm + Hs-Source-Dirs: src, src/Parse, src/Types + other-modules: Ast, CompileToJS, GenerateHtml, Guid, Initialize, + Rename, Binop, Combinators, Lexer, + ParsePatterns, Parser, ParserLib, ParseTypes, Tokens, + Types, Constrain, Hints, Types, Unify \ No newline at end of file diff --git a/src/Elm.hs b/src/Compiler.hs similarity index 92% rename from src/Elm.hs rename to src/Compiler.hs index 01816d5..9a67096 100644 --- a/src/Elm.hs +++ b/src/Compiler.hs @@ -10,7 +10,7 @@ import Text.Blaze.Html.Renderer.String (renderHtml) main = getArgs >>= parse parse ("--help":_) = putStrLn usage -parse ("--version":_) = putStrLn "The Elm Compiler 0.1.0" +parse ("--version":_) = putStrLn "The Elm Compiler 0.1.1.1" parse [loc,file] | "--runtime-location=" `isPrefixOf` loc = produceHtml (tail $ dropWhile (/='=') loc) file diff --git a/src/Initialize.hs b/src/Initialize.hs index 14891f5..8ed8de4 100644 --- a/src/Initialize.hs +++ b/src/Initialize.hs @@ -6,11 +6,9 @@ import Control.Monad import Data.Char (isAlpha) import Data.Maybe (mapMaybe) import Data.Either (rights) -import FreeVar import Lexer import Parser (toExpr,toDefs) import Rename (rename) -import Replace import Unify import Hints diff --git a/src/Language/Elm.hs b/src/Language/Elm.hs new file mode 100644 index 0000000..449c393 --- /dev/null +++ b/src/Language/Elm.hs @@ -0,0 +1,10 @@ + +module Language.Elm where + +import CompileToJS +import GenerateHtml +import Text.Blaze.Html (Html) + +compileToHtml :: String -> String -> String -> Html +compileToHtml libLoc fileName source = + generateHtml libLoc fileName (compileToJS source) \ No newline at end of file diff --git a/src/Server.hs b/src/Server.hs index 36723a3..5fe6917 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -7,28 +7,31 @@ import Data.List (isPrefixOf, isSuffixOf) import Happstack.Server import Happstack.Server.Compression import System.Environment -import ToHtml +import Language.Elm serve :: String -> IO () serve libLoc = do - putStrLn "Elm Server 0.1.0: running at " + putStrLn "Elm Server 0.1.1.1: running at " simpleHTTP nullConf $ do compressedResponseFilter msum [ uriRest (serveElm libLoc) , serveDirectory EnableBrowsing [] "." ] +pageTitle fp = + reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp + serveElm libLoc fp = do let ('/':path) = fp guard (".elm" `isSuffixOf` path) content <- liftIO (readFile path) - ok . toResponse $ compileToHtml libLoc path content + ok . toResponse $ compileToHtml libLoc (pageTitle path) content main = getArgs >>= parse parse ("--help":_) = putStrLn usage -parse ("--version":_) = putStrLn "The Elm Server 0.1.0" +parse ("--version":_) = putStrLn "The Elm Server 0.1.1.1" parse [] = serve "/elm-mini.js" parse [arg] | "--runtime-location=" `isPrefixOf` arg = diff --git a/src/ToHtml.hs b/src/ToHtml.hs deleted file mode 100644 index 0d7b565..0000000 --- a/src/ToHtml.hs +++ /dev/null @@ -1,14 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -module ToHtml (compileToHtml) where - -import CompileToJS -import GenerateHtml -import qualified Text.Blaze.Html5 as H -import qualified Text.Blaze.Html5.Attributes as A - -pageTitle fp = - reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp - -compileToHtml :: String -> String -> String -> H.Html -compileToHtml libLoc fileName source = - generateHtml libLoc (pageTitle fileName) (compileToJS source) \ No newline at end of file