Prepare for second release.
Add a Haskell library so that Elm code can be compiled directly in Haskell. Clean up file names and fix up dependencies.
This commit is contained in:
parent
e33d3290e3
commit
8215dacbab
6 changed files with 36 additions and 31 deletions
28
Elm.cabal
28
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
|
|
@ -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
|
|
@ -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
|
||||
|
|
10
src/Language/Elm.hs
Normal file
10
src/Language/Elm.hs
Normal file
|
@ -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)
|
|
@ -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 <http://localhost:8000>"
|
||||
putStrLn "Elm Server 0.1.1.1: running at <http://localhost:8000>"
|
||||
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 =
|
||||
|
|
|
@ -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)
|
Loading…
Reference in a new issue