on master help sign in
Merge remote-tracking branch 'evan/dev' into webgl
9843312John P Mayer Jr
Elm.cabal+3−3
@@ -97,7 +97,7 @@ Library
97 Build-depends: aeson,
97 Build-depends: aeson,
98 base >=4.2 && <5,
98 base >=4.2 && <5,
99 binary >= 0.6.4.0,
99 binary >= 0.6.4.0,
100− blaze-html == 0.5.* || == 0.6.*,
100+ blaze-html >= 0.5 && < 0.8,
101 blaze-markup,
101 blaze-markup,
102 bytestring,
102 bytestring,
103 cmdargs,
103 cmdargs,
@@ -180,8 +180,8 @@ Executable elm
180 Build-depends: aeson,
180 Build-depends: aeson,
181 base >=4.2 && <5,
181 base >=4.2 && <5,
182 binary >= 0.6.4.0,
182 binary >= 0.6.4.0,
183− blaze-html == 0.5.* || == 0.6.*,
183+ blaze-html >= 0.5 && < 0.8,
184− blaze-markup == 0.5.1.*,
184+ blaze-markup,
185 bytestring,
185 bytestring,
186 cmdargs,
186 cmdargs,
187 containers >= 0.3,
187 containers >= 0.3,
compiler/Generate/JavaScript/Ports.hs+1−1
@@ -109,7 +109,7 @@ out tipe x =
109 | ctor == "Maybe.Maybe" ->
109 | ctor == "Maybe.Maybe" ->
110 CondExpr () (equal (DotRef () x (var "ctor")) (string "Nothing"))
110 CondExpr () (equal (DotRef () x (var "ctor")) (string "Nothing"))
111 (NullLit ())
111 (NullLit ())
112− (DotRef () x (var "_0"))
112+ (out t (DotRef () x (var "_0")))
113
113
114 | ctor == "_List" ->
114 | ctor == "_List" ->
115 DotRef () (obj "_J.fromList" <| x) (var "map") <| outgoing t
115 DotRef () (obj "_J.fromList" <| x) (var "map") <| outgoing t
compiler/Parse/Expression.hs+2−2
@@ -66,11 +66,11 @@ listTerm = markdown' <|> glShader' <|> braces (try range <|> ExplicitList <$> co
66 span uid index =
66 span uid index =
67 "<span id=\"md-" ++ uid ++ "-" ++ show index ++ "\">{{ markdown interpolation is in the pipeline, but still needs more testing }}</span>"
67 "<span id=\"md-" ++ uid ++ "-" ++ show index ++ "\">{{ markdown interpolation is in the pipeline, but still needs more testing }}</span>"
68
68
69− interpolation uid md exprs = do
69+ interpolation uid exprs = do
70 try (string "{{")
70 try (string "{{")
71 e <- padded expr
71 e <- padded expr
72 string "}}"
72 string "}}"
73− return (md ++ span uid (length exprs), exprs ++ [e])
73+ return (span uid (length exprs), exprs ++ [e])
74
74
75parensTerm :: IParser LParseExpr
75parensTerm :: IParser LParseExpr
76parensTerm = try (parens opFn) <|> parens (tupleFn <|> parened)
76parensTerm = try (parens opFn) <|> parens (tupleFn <|> parened)
compiler/Parse/Helpers.hs+6−6
@@ -271,7 +271,7 @@ ignoreUntil end = go
271 ignore p = const () <$> p
271 ignore p = const () <$> p
272 filler = choice [ try (ignore chr) <|> ignore str
272 filler = choice [ try (ignore chr) <|> ignore str
273 , ignore multiComment
273 , ignore multiComment
274− , ignore (markdown (\_ _ -> mzero))
274+ , ignore (markdown (\_ -> mzero))
275 , ignore anyChar
275 , ignore anyChar
276 ]
276 ]
277 go = choice [ Just <$> end
277 go = choice [ Just <$> end
@@ -304,15 +304,15 @@ anyUntilPos pos = go
304 True -> return []
304 True -> return []
305 False -> (:) <$> anyChar <*> go
305 False -> (:) <$> anyChar <*> go
306
306
307−markdown :: (String -> [a] -> IParser (String, [a])) -> IParser (String, [a])
307+markdown :: ([a] -> IParser (String, [a])) -> IParser (String, [a])
308−markdown interpolation = try (string "[markdown|") >> closeMarkdown "" []
308+markdown interpolation = try (string "[markdown|") >> closeMarkdown (++ "") []
309 where
309 where
310 closeMarkdown md stuff =
310 closeMarkdown md stuff =
311 choice [ do try (string "|]")
311 choice [ do try (string "|]")
312− return (md, stuff)
312+ return (md "", stuff)
313− , uncurry closeMarkdown =<< interpolation md stuff
313+ , (\(m,s) -> closeMarkdown (md . (m ++)) s) =<< interpolation stuff
314 , do c <- anyChar
314 , do c <- anyChar
315− closeMarkdown (md ++ [c]) stuff
315+ closeMarkdown (md . ([c]++)) stuff
316 ]
316 ]
317
317
318glShader :: IParser (String, Literal.GLShaderTipe)
318glShader :: IParser (String, Literal.GLShaderTipe)
compiler/SourceSyntax/Module.hs+31−1
@@ -1,12 +1,15 @@
1−{-# OPTIONS_GHC -Wall #-}
1+{-# OPTIONS_GHC -W #-}
2module SourceSyntax.Module where
2module SourceSyntax.Module where
3
3
4import Data.Binary
4import Data.Binary
5+import qualified Data.List as List
5import qualified Data.Map as Map
6import qualified Data.Map as Map
6import Control.Applicative ((<$>), (<*>))
7import Control.Applicative ((<$>), (<*>))
8+import Text.PrettyPrint as P
7
9
8import SourceSyntax.Expression (LExpr)
10import SourceSyntax.Expression (LExpr)
9import SourceSyntax.Declaration
11import SourceSyntax.Declaration
12+import SourceSyntax.PrettyPrint
10import SourceSyntax.Type
13import SourceSyntax.Type
11
14
12import qualified Elm.Internal.Version as Version
15import qualified Elm.Internal.Version as Version
@@ -21,6 +24,33 @@ type Imports = [(String, ImportMethod)]
21data ImportMethod = As String | Importing [String] | Hiding [String]
24data ImportMethod = As String | Importing [String] | Hiding [String]
22 deriving (Eq, Ord, Show)
25 deriving (Eq, Ord, Show)
23
26
27+instance (Pretty def) => Pretty (Module def) where
28+ pretty (Module modNames exports imports decls) =
29+ P.vcat [modul, P.text "", prettyImports, P.text "", prettyDecls]
30+ where
31+ prettyDecls = P.sep $ map pretty decls
32+
33+ modul = P.text "module" <+> moduleName <+> where'
34+ moduleName = P.text $ List.intercalate "." modNames
35+ where' =
36+ case exports of
37+ [] -> P.text "where"
38+ _ -> P.parens (commaCat $ map P.text exports) <+> P.text "where"
39+
40+ prettyImports = P.vcat $ map prettyImport imports
41+
42+ prettyImport (name, method) =
43+ P.text "import" <+>
44+ case method of
45+ As alias ->
46+ P.text $ name ++ (if name == alias then "" else " as " ++ alias)
47+
48+ Importing values ->
49+ P.text name <+> P.parens (commaCat (map P.text values))
50+
51+ Hiding [] -> P.text ("open " ++ name)
52+ Hiding _ -> error "invalid import declaration"
53+
24instance Binary ImportMethod where
54instance Binary ImportMethod where
25 put method =
55 put method =
26 let put' n info = putWord8 n >> put info in
56 let put' n info = putWord8 n >> put info in
libraries/Native/Bitwise.js+6−6
@@ -13,13 +13,13 @@ Elm.Native.Bitwise.make = function(elm) {
13 function srl(a,offset) { return a >>> offset; }
13 function srl(a,offset) { return a >>> offset; }
14
14
15 return elm.Native.Bitwise.values = {
15 return elm.Native.Bitwise.values = {
16− and: A2(and),
16+ and: F2(and),
17− or : A2(or ),
17+ or : F2(or ),
18− xor: A2(xor),
18+ xor: F2(xor),
19 complement: not,
19 complement: not,
20− shiftLeft : A2(sll),
20+ shiftLeft : F2(sll),
21− shiftRightArithmatic: A2(sra),
21+ shiftRightArithmatic: F2(sra),
22− shiftRightLogical : A2(srl),
22+ shiftRightLogical : F2(srl),
23 };
23 };
24
24
25};
25};