Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
elm-lang/elm-compiler
5outh/Elm
8l/elm-compiler
A1kmm/Elm
AdrianoFerrari/elm-compiler
Apanatshka/Elm
Axure/elm-compiler
CNXTEoEorg/elm-compiler
CODECOMMUNITY/elm-compiler
Dandandan/elm-compiler
DonaldScott/Elm
DylanSale/Elm
FPtje/elm-compiler
Fengmaolu/elm-compiler
FreeKillz/Elm
Gaafar/elm-compiler
GoranM/Elm
HOLYCOWBATMAN/Elm
Heimdell/Elm
JoeyEremondi/elm-compiler
KevinKelley/Elm
MaxGabriel/elm-compiler
Raynos/Elm
Sheeo/Elm
TheunisKotze/Elm
ThomasWeiser/elm-compiler
VISCHub/elm-compiler
WraithM/Elm
Xashili/Elm
Zert/elm-compiler
aforemny/Elm
agrafix/elm-compiler
alexander-b/Elm
alexspurling/elm-compiler
andrewsw/Elm
arianvp/Elm
ashleyburgess/Elm
asolove/Elm
avh4/elm-compiler
bftjoe/Elm
bolmar/Elm
botandrose/elm-compiler
brendanzab/elm-compiler
chaosim/Elm
chreekat/Elm
cies/Elm
codecurve/Elm
creativeprogramming/Elm
cris/Elm
cstork/Elm
davejachimiak/elm-compiler
davidfstr/Elm
deadfoxygrandpa/Elm
devth/Elm
dfeltey/Elm
dfordivam/elm-compiler
dharmatech/Elm
dmalves/elm-compiler
dobesv/Elm
doubleyou/Elm
drozv/Elm
dvdtoth/Elm
ealter/Elm
ecolog/elm-compiler
eeue56/elm-compiler
egonSchiele/elm-compiler
exFalso/Elm
fabianpage/Elm
fgc/Elm
fivejjs/Elm
flbulgarelli/Elm
fosskers/Elm
ga2arch/Elm
gartenlaub/Elm
ghosthamlet/Elm
giisyu/elm-compiler
glutamate/Elm
grotsev/Elm
guillaume-nargeot/elm-compiler
hagemt/Elm
halacsy/Elm
hariomrana/Elm
henrik/elm-compiler
hidecology/Elm
ianbollinger/elm-compiler
ianoc/elm-compiler
igrep/elm-compiler
ilovejs/Elm
imeckler/elm-compiler
ivanov/Elm
jamiepg1/Elm
jcollard/elm-compiler
jdeveloper/Elm
jdudek/elm-compiler
jeffpeterson/elm-compiler
jessab/Elm
jgrimes/Elm
jice/Elm
joeyadams/Elm
johnpmayer/elm-compiler
jonathanperret/elm-compiler
joseph-hurtado/Elm
jsl/Elm
jtneill/elm-compiler
juhp/Elm
jushaox/elm-compiler
justinmanley/elm-compiler
kcbsbo/elm-compiler
kjgorman/Elm
knurt/Elm
krsreenatha/Elm
laszlopandy/elm-compiler
leocassarani/elm-compiler
longde123/Elm
lucciano/Elm
madsflensted/Elm
manishjhawar/Elm
markflorisson/elm-compiler
marklar/Elm
marzhall/Elm
maurisvh/elm-compiler
maxsnew/elm-compiler
mcveat/Elm
mg50/Elm
mgold/Elm
michaelbjames/Elm
micmarsh/Elm
mikepence/Elm
mohamadzali/Elm
mohidmakhdoomi/elm-compiler
mthurman/elm-compiler
mxswd/Elm
nathan/elm-compiler
neerajwahi/Elm
neo4reo/Elm
newtriks/elm-compiler
ngunn/Elm
notnew/Elm
ohanhi/elm-compiler
osa1/Elm
osnr/Elm
outamaa/Elm
ozataman/Elm
pboyer/elm-compiler
perplexes/Elm
pkamenarsky/Elm
pkdevbox/elm-compiler
pombreda/elm-compiler
pullmonkey/Elm
pythonesque/elm-compiler
r3m0t/Elm
ramons03/Elm
rehno-lindeque/elm-compiler
rex1fernando/Elm
rlugojr/elm-compiler
rmoorman/Elm
rowhit/elm-compiler
rtfeldman/elm-compiler
ryanmtaylor/elm-compiler
rylev/Elm
santhosh1234/Elm
sarvex/elm-compiler
seancorfield/elm-compiler
seliopou/Elm
sgillis/elm-compiler
sgraf812/elm-compiler
shashi/Elm
silky/Elm
slevin/Elm
snchong/Elm
srijs/elm-compiler
stevenheidel/elm-compiler
stonly/Elm
sumguysr/Elm
sutiandong/Elm
talon/Elm
techtangents/Elm
thSoft/Elm
thinkpad20/Elm
thomasbhatia/Elm
timjb/Elm
timthelion/Noelm
tinco/Elm
transformersprimeabcxyz/elm-compiler
trizko/elm-compiler
tsaiDavid/elm-compiler
tzbob/elm-compiler
vbychkovsky/Elm
wighawag/Elm
wires/Elm
won21kr/Elm
wy931207/elm-compiler
xeronith/elm-compiler
yogsototh/Elm
yonglehou/elm-compiler
yuriy0/elm-compiler
zarvunk/elm-compiler
zhuomingliang/elm-compiler
zmthy/Elm
zsombornagy/Elm
Nothing to show
Choose a base branch
Nothing to show
...
Choose a Head Repository
elm-lang/elm-compiler
5outh/Elm
8l/elm-compiler
A1kmm/Elm
AdrianoFerrari/elm-compiler
Apanatshka/Elm
Axure/elm-compiler
CNXTEoEorg/elm-compiler
CODECOMMUNITY/elm-compiler
Dandandan/elm-compiler
DonaldScott/Elm
DylanSale/Elm
FPtje/elm-compiler
Fengmaolu/elm-compiler
FreeKillz/Elm
Gaafar/elm-compiler
GoranM/Elm
HOLYCOWBATMAN/Elm
Heimdell/Elm
JoeyEremondi/elm-compiler
KevinKelley/Elm
MaxGabriel/elm-compiler
Raynos/Elm
Sheeo/Elm
TheunisKotze/Elm
ThomasWeiser/elm-compiler
VISCHub/elm-compiler
WraithM/Elm
Xashili/Elm
Zert/elm-compiler
aforemny/Elm
agrafix/elm-compiler
alexander-b/Elm
alexspurling/elm-compiler
andrewsw/Elm
arianvp/Elm
ashleyburgess/Elm
asolove/Elm
avh4/elm-compiler
bftjoe/Elm
bolmar/Elm
botandrose/elm-compiler
brendanzab/elm-compiler
chaosim/Elm
chreekat/Elm
cies/Elm
codecurve/Elm
creativeprogramming/Elm
cris/Elm
cstork/Elm
davejachimiak/elm-compiler
davidfstr/Elm
deadfoxygrandpa/Elm
devth/Elm
dfeltey/Elm
dfordivam/elm-compiler
dharmatech/Elm
dmalves/elm-compiler
dobesv/Elm
doubleyou/Elm
drozv/Elm
dvdtoth/Elm
ealter/Elm
ecolog/elm-compiler
eeue56/elm-compiler
egonSchiele/elm-compiler
exFalso/Elm
fabianpage/Elm
fgc/Elm
fivejjs/Elm
flbulgarelli/Elm
fosskers/Elm
ga2arch/Elm
gartenlaub/Elm
ghosthamlet/Elm
giisyu/elm-compiler
glutamate/Elm
grotsev/Elm
guillaume-nargeot/elm-compiler
hagemt/Elm
halacsy/Elm
hariomrana/Elm
henrik/elm-compiler
hidecology/Elm
ianbollinger/elm-compiler
ianoc/elm-compiler
igrep/elm-compiler
ilovejs/Elm
imeckler/elm-compiler
ivanov/Elm
jamiepg1/Elm
jcollard/elm-compiler
jdeveloper/Elm
jdudek/elm-compiler
jeffpeterson/elm-compiler
jessab/Elm
jgrimes/Elm
jice/Elm
joeyadams/Elm
johnpmayer/elm-compiler
jonathanperret/elm-compiler
joseph-hurtado/Elm
jsl/Elm
jtneill/elm-compiler
juhp/Elm
jushaox/elm-compiler
justinmanley/elm-compiler
kcbsbo/elm-compiler
kjgorman/Elm
knurt/Elm
krsreenatha/Elm
laszlopandy/elm-compiler
leocassarani/elm-compiler
longde123/Elm
lucciano/Elm
madsflensted/Elm
manishjhawar/Elm
markflorisson/elm-compiler
marklar/Elm
marzhall/Elm
maurisvh/elm-compiler
maxsnew/elm-compiler
mcveat/Elm
mg50/Elm
mgold/Elm
michaelbjames/Elm
micmarsh/Elm
mikepence/Elm
mohamadzali/Elm
mohidmakhdoomi/elm-compiler
mthurman/elm-compiler
mxswd/Elm
nathan/elm-compiler
neerajwahi/Elm
neo4reo/Elm
newtriks/elm-compiler
ngunn/Elm
notnew/Elm
ohanhi/elm-compiler
osa1/Elm
osnr/Elm
outamaa/Elm
ozataman/Elm
pboyer/elm-compiler
perplexes/Elm
pkamenarsky/Elm
pkdevbox/elm-compiler
pombreda/elm-compiler
pullmonkey/Elm
pythonesque/elm-compiler
r3m0t/Elm
ramons03/Elm
rehno-lindeque/elm-compiler
rex1fernando/Elm
rlugojr/elm-compiler
rmoorman/Elm
rowhit/elm-compiler
rtfeldman/elm-compiler
ryanmtaylor/elm-compiler
rylev/Elm
santhosh1234/Elm
sarvex/elm-compiler
seancorfield/elm-compiler
seliopou/Elm
sgillis/elm-compiler
sgraf812/elm-compiler
shashi/Elm
silky/Elm
slevin/Elm
snchong/Elm
srijs/elm-compiler
stevenheidel/elm-compiler
stonly/Elm
sumguysr/Elm
sutiandong/Elm
talon/Elm
techtangents/Elm
thSoft/Elm
thinkpad20/Elm
thomasbhatia/Elm
timjb/Elm
timthelion/Noelm
tinco/Elm
transformersprimeabcxyz/elm-compiler
trizko/elm-compiler
tsaiDavid/elm-compiler
tzbob/elm-compiler
vbychkovsky/Elm
wighawag/Elm
wires/Elm
won21kr/Elm
wy931207/elm-compiler
xeronith/elm-compiler
yogsototh/Elm
yonglehou/elm-compiler
yuriy0/elm-compiler
zarvunk/elm-compiler
zhuomingliang/elm-compiler
zmthy/Elm
zsombornagy/Elm
Nothing to show
Choose a head branch
Nothing to show
  • 7 commits
  • 14 files changed
  • 0 commit comments
  • 1 contributor
Showing with 68 additions and 64 deletions.
  1. +9 −5 Elm.cabal
  2. +2 −0 src/Ast.hs
  3. +1 −0 src/CompileToJS.hs
  4. +1 −1 src/Elm.hs
  5. +21 −20 src/GenerateHtml.hs
  6. +1 −1 src/Parse/Binop.hs
  7. +3 −3 src/Parse/Combinators.hs
  8. +1 −1 src/Parse/Parser.hs
  9. +2 −6 src/Server.hs
  10. +1 −6 src/ToHtml.hs
  11. +3 −10 src/Types/Constrain.hs
  12. +2 −3 src/Types/Hints.hs
  13. +1 −1 src/Types/Types.hs
  14. +20 −7 src/Types/Unify.hs
View
@@ -37,22 +37,26 @@ Executable elm
Types
-- Packages needed in order to build this package.
- Build-depends: base >=4.2 && <5, containers >= 0.3, transformers >= 0.2,
- mtl >= 2, parsec >= 3.1.1, blaze-html >=0.4 && <0.5
+ 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.*, blaze-markup == 0.5.1.*, deepseq
-- Modules not exported by this package.
-- Other-modules:
-- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
-- Build-tools:
-
+
+
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,
ParsePatterns, Parser, ParserLib, ParseTypes, Tokens,
Types
+ 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.4 && <0.5,
- HTTP >= 4000, happstack-server >= 6.2.4
+ mtl >= 2, parsec >= 3.1.1, blaze-html == 0.5.0.*,
+ HTTP >= 4000, happstack-server == 7.0.2
View
@@ -1,10 +1,12 @@
+
module Ast where
data Pattern = PData String [Pattern] | PVar String | PAnything
deriving (Show, Eq)
data Expr = Number Int
| Chr Char
+ | Str String
| Boolean Bool
| Range Expr Expr
| Access Expr String
View
@@ -27,6 +27,7 @@ toJS expr =
Number n -> show n
Var x -> x
Chr c -> show c
+ Str s -> toJS . list $ map Chr s
Boolean b -> if b then "true" else "false"
Range lo hi -> jsRange (toJS lo) (toJS hi)
Access e lbl -> toJS e ++ "." ++ lbl
View
@@ -5,7 +5,7 @@ import System.Environment
import CompileToJS
import Data.List (isPrefixOf)
import GenerateHtml
-import Text.Blaze.Renderer.String
+import Text.Blaze.Html.Renderer.String (renderHtml)
main = getArgs >>= parse
View
@@ -1,32 +1,33 @@
{-# LANGUAGE OverloadedStrings #-}
module GenerateHtml (generateHtml) where
-import Text.Blaze.Html5 hiding (map)
+import Text.Blaze (preEscapedToMarkup)
import qualified Text.Blaze.Html5 as H
-import Text.Blaze.Html5.Attributes
+import Text.Blaze.Html5 ((!))
import qualified Text.Blaze.Html5.Attributes as A
-css = preEscapedString "* { padding:0; margin:0; \
- \hyphens: auto; -moz-hyphens: auto;\
- \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
- \body { font-family: Arial; }\
- \a:link {text-decoration: none}\
- \a:visited {text-decoration: none}\
- \a:active {text-decoration: none}\
- \a:hover {text-decoration: underline; color: #ff8f12;}"
-
-makeScript :: String -> Html
-makeScript s = script ! type_ "text/javascript" ! src (toValue s) $ ""
+css = preEscapedToMarkup $
+ ("* { padding:0; margin:0; \
+ \hyphens: auto; -moz-hyphens: auto;\
+ \ -webkit-hyphens: auto; -ms-hyphens: auto; }\
+ \body { font-family: Arial; }\
+ \a:link {text-decoration: none}\
+ \a:visited {text-decoration: none}\
+ \a:active {text-decoration: none}\
+ \a:hover {text-decoration: underline; color: #ff8f12;}" :: String)
+
+makeScript :: String -> H.Html
+makeScript s = H.script ! A.type_ "text/javascript" ! A.src (H.toValue s) $ ""
generateHtml libLoc title source =
- docTypeHtml $ do
+ H.docTypeHtml $ do
H.head $ do
- meta ! charset "UTF-8"
- H.title . toHtml $ title
+ H.meta ! A.charset "UTF-8"
+ H.title . H.toHtml $ title
makeScript libLoc
- (script ! type_ "text/javascript") . preEscapedString $ source
- H.style ! type_ "text/css" $ css
- body $ do
+ (H.script ! A.type_ "text/javascript") . preEscapedToMarkup $ source
+ H.style ! A.type_ "text/css" $ css
+ H.body $ do
H.div ! A.id "widthChecker" ! A.style "width:100%; height:1px; position:absolute; top:-1px;" $ ""
H.span ! A.id "content" $ ""
- script ! type_ "text/javascript" $ "Dispatcher.initialize()"
+ H.script ! A.type_ "text/javascript" $ "Dispatcher.initialize()"
View
@@ -39,7 +39,7 @@ binopSplit seen opTable i ops es =
binopOf _ _ _ [e] = return e
binopOf _ [] ops es =
- return $ foldl (flip ($)) (head es) $ zipWith Binop ops (tail es)
+ return $ foldl' (flip ($)) (head es) $ zipWith Binop ops (tail es)
binopOf seen (tbl@((lvl, L, op):rest)) ops es =
case elemIndices op ops of
View
@@ -1,7 +1,7 @@
module Combinators where
import Control.Monad
import Data.Char
-import Data.List (sortBy)
+import Data.List (sortBy,foldl',foldl1')
newtype Parser from to = Parser ([from] -> [(to,[from])])
--newtype Parser a = Parser (String -> [(a,String)])
@@ -52,7 +52,7 @@ newline = do
return ""
digit = do {x <- sat isDigit; return (ord x - ord '0')}
-integer = do {i <- plus digit; return $ foldl (\a d -> 10 * a + d) 0 i}
+integer = do {i <- plus digit; return $ foldl' (\a d -> 10 * a + d) 0 i}
variable = do
shd <- sat isLower;
@@ -66,7 +66,7 @@ sepBy1 sep p = do
xs <- star (sep >> p)
return $ x:xs
-select = foldl1 (+|+)
+select = foldl1' (+|+)
chainl p op a = chainl1 p op +++ return a
chainl1 p op = do {a <- p; rest a}
View
@@ -18,7 +18,7 @@ import Types (Type (VarT))
numTerm = do { whitespace; t <- item
; case t of { NUMBER n -> return $ Number n; _ -> zero } }
strTerm = do { whitespace; t <- item
- ; case t of { STRING cs -> return . list $ map Chr cs
+ ; case t of { STRING cs -> return $ Str cs
; _ -> zero } }
varTerm = Var `liftM` var
View
@@ -1,16 +1,12 @@
-{-# LANGUAGE OverloadedStrings #-}
+
module Main where
-import Prelude hiding (head,span,id)
import Control.Monad (msum,guard)
import Control.Monad.Trans (MonadIO(liftIO))
import Data.List (isPrefixOf, isSuffixOf)
-import Happstack.Server hiding (body)
+import Happstack.Server
import Happstack.Server.Compression
import System.Environment
-import Text.Blaze.Html5 hiding (map)
-import Text.Blaze.Html5.Attributes hiding (title,span,dir,style)
-import Text.Blaze.Internal
import ToHtml
serve :: String -> IO ()
View
@@ -2,18 +2,13 @@
module ToHtml (compileToHtml) where
import CompileToJS
-import Data.Monoid (mempty)
import GenerateHtml
-import Network.HTTP.Base (urlEncode)
-import Text.Blaze.Html5 hiding (map)
import qualified Text.Blaze.Html5 as H
-import Text.Blaze.Html5.Attributes
import qualified Text.Blaze.Html5.Attributes as A
pageTitle fp =
reverse . takeWhile (/='/') . drop 1 . dropWhile (/='.') $ reverse fp
-
-compileToHtml :: String -> String -> String -> Html
+compileToHtml :: String -> String -> String -> H.Html
compileToHtml libLoc fileName source =
generateHtml libLoc (pageTitle fileName) (compileToJS source)
View
@@ -3,6 +3,7 @@ module Constrain where
import Ast
import Types
+import Data.List (foldl')
import qualified Data.Set as Set
import qualified Data.Map as Map
import Control.Monad (liftM,mapM)
@@ -60,7 +61,7 @@ inference (If e1 e2 e3) =
, Set.unions [c1,c2,c3, Set.fromList [ t1 :=: BoolT, t2 :=: t3 ] ]
, t2 )
-inference (Data name es) = inference $ foldl App (Var name) es
+inference (Data name es) = inference $ foldl' App (Var name) es
inference (Binop op e1 e2) = inference (Var op `App` e1 `App` e2)
inference (Access (Var x) y) = inference . Var $ x ++ "." ++ y
inference (Range e1 e2) = inference (Var "elmRange" `App` e1 `App` e2)
@@ -69,16 +70,8 @@ inference other =
case other of
Number _ -> primitive IntT
Chr _ -> primitive CharT
+ Str _ -> primitive string
Boolean _ -> primitive BoolT
_ -> beta >>= primitive
primitive t = return (Map.empty, Set.empty, t)
-{--
- Let x e1 e2 ->
- do (a1,c1,t1) <- inference e1
- (a2,c2,t2) <- inference e2
- let ts = Map.findWithDefault (error "inference") x a
- return ( unionA a1 $ Map.delete x a2
- , Set.unions [ c1, c2, Set.fromList $ map (:<: t1) ts ]
- , t2 )
---}
View
@@ -11,7 +11,7 @@ import Guid
str2elem = hasType (string ==> element) [ "image","video","plainText" ]
-textToText = ["header", "italic", "bold", "underline"
+textToText = [ "header", "italic", "bold", "underline"
, "overline", "strikeThrough", "monospace" ]
textAttrs = [ "toText" -: string ==> text
@@ -102,5 +102,4 @@ lists = liftM (map (first ("List."++)) . (++ints)) . sequence $
hints = do
fs <- funcs ; ls <- lists
- return $ fs ++ ls ++ math ++ bool
- {--++ str2elem ++ textAttrs ++ elements--}
+ return $ fs ++ ls ++ math ++ bool ++ str2elem ++ textAttrs ++ elements
View
@@ -19,7 +19,7 @@ data Scheme = Forall (Set.Set X) Type deriving (Eq, Ord, Show)
element = ADT "Element" []
direction = ADT "Direction" []
-text = ADT "Text" []
+text = ADT "List" [ADT "text" []]
listOf t = ADT "List" [t]
tupleOf ts = ADT ("Tuple" ++ show (length ts)) ts
string = listOf CharT
View
@@ -4,10 +4,23 @@ module Unify where
import Constrain
import Control.Arrow (second)
import Control.Monad (liftM)
+import Data.List (foldl')
import qualified Data.Set as Set
+import Guid
import Types
-import Guid
+import Control.DeepSeq
+
+force x = x `deepseq` x
+
+instance NFData Constraint where
+ rnf (t1 :=: t2) = t1 `deepseq` t2 `deepseq` ()
+ rnf (t1 :<: t2) = t1 `deepseq` t2 `deepseq` ()
+
+instance NFData Type where
+ rnf (LambdaT t1 t2) = t1 `deepseq` t2 `deepseq` ()
+ rnf (ADT _ ts) = foldl' (\acc x -> x `deepseq` acc) () ts
+ rnf t = t `seq` ()
unify hints expr = run $ do
cs <- constrain hints expr
@@ -36,16 +49,16 @@ solver ((t1 :=: t2) : cs) subs =
solver ((t1 :<: t2) : cs) subs = do
let f x = do y <- guid ; return (x,VarT y)
- t2' <- foldr (uncurry tSub) t2 `liftM` (mapM f . Set.toList $ getVars t2)
+ t2' <- foldl' (uncurry . flip tSub) t2 `liftM` (mapM f . Set.toList $ getVars t2)
solver ((t1 :=: t2') : cs) subs
-cSub k v (t1 :=: t2) = tSub k v t1 :=: tSub k v t2
-cSub k v (t1 :<: t2) = tSub k v t1 :<: tSub k v t2
+cSub k v (t1 :=: t2) = force $ tSub k v t1 :=: tSub k v t2
+cSub k v (t1 :<: t2) = force $ tSub k v t1 :<: tSub k v t2
-tSub k v (VarT x) = if k == x then v else (VarT x)
-tSub k v (LambdaT t1 t2) = LambdaT (tSub k v t1) (tSub k v t2)
-tSub k v (ADT name ts) = ADT name (map (tSub k v) ts)
+tSub k v t@(VarT x) = if k == x then v else t
+tSub k v (LambdaT t1 t2) = force $ LambdaT (tSub k v t1) (tSub k v t2)
+tSub k v (ADT name ts) = ADT name (map (force . tSub k v) ts)
tSub _ _ t = t
getVars (VarT x) = Set.singleton x

No commit comments for this range