on master help sign in
Merge branch 'master' into debugger
e7dce9eEvan Czaplicki
Elm.cabal+10−16
@@ -106,23 +106,22 @@ Library
106 blaze-html >= 0.5 && < 0.8,
106 blaze-html >= 0.5 && < 0.8,
107 blaze-markup,
107 blaze-markup,
108 bytestring,
108 bytestring,
109+ cheapskate,
109 cmdargs,
110 cmdargs,
110 containers >= 0.3,
111 containers >= 0.3,
111 directory,
112 directory,
112 filepath,
113 filepath,
114+ highlighting-kate,
113 indents,
115 indents,
114 language-ecmascript >=0.15 && < 1.0,
116 language-ecmascript >=0.15 && < 1.0,
115 language-glsl >= 0.0.2,
117 language-glsl >= 0.0.2,
116 mtl >= 2,
118 mtl >= 2,
117− pandoc >= 1.10,
118 parsec >= 3.1.1,
119 parsec >= 3.1.1,
119 pretty,
120 pretty,
120− scientific,
121 text,
121 text,
122 transformers >= 0.2,
122 transformers >= 0.2,
123 union-find,
123 union-find,
124− unordered-containers,
124+ unordered-containers
125− yaml
126
125
127Executable elm
126Executable elm
128 Main-is: Compiler.hs
127 Main-is: Compiler.hs
@@ -197,23 +196,22 @@ Executable elm
197 blaze-html >= 0.5 && < 0.8,
196 blaze-html >= 0.5 && < 0.8,
198 blaze-markup,
197 blaze-markup,
199 bytestring,
198 bytestring,
199+ cheapskate,
200 cmdargs,
200 cmdargs,
201 containers >= 0.3,
201 containers >= 0.3,
202 directory,
202 directory,
203 filepath,
203 filepath,
204+ highlighting-kate,
204 indents,
205 indents,
205 language-ecmascript >=0.15 && < 1.0,
206 language-ecmascript >=0.15 && < 1.0,
206 language-glsl >= 0.0.2,
207 language-glsl >= 0.0.2,
207 mtl >= 2,
208 mtl >= 2,
208− pandoc >= 1.10,
209 parsec >= 3.1.1,
209 parsec >= 3.1.1,
210− scientific,
211 pretty,
210 pretty,
212 text,
211 text,
213 transformers >= 0.2,
212 transformers >= 0.2,
214 union-find,
213 union-find,
215− unordered-containers,
214+ unordered-containers
216− yaml
217
215
218Executable elm-doc
216Executable elm-doc
219 Main-is: Docs.hs
217 Main-is: Docs.hs
@@ -249,14 +247,11 @@ Executable elm-doc
249 indents,
247 indents,
250 language-glsl >= 0.0.2,
248 language-glsl >= 0.0.2,
251 mtl >= 2,
249 mtl >= 2,
252− pandoc >= 1.10,
253 parsec >= 3.1.1,
250 parsec >= 3.1.1,
254 pretty,
251 pretty,
255− scientific,
256 text,
252 text,
257 transformers >= 0.2,
253 transformers >= 0.2,
258− union-find,
254+ union-find
259− yaml
260
255
261Test-Suite compiler-tests
256Test-Suite compiler-tests
262 Type: exitcode-stdio-1.0
257 Type: exitcode-stdio-1.0
@@ -280,25 +275,24 @@ Test-Suite compiler-tests
280 blaze-html,
275 blaze-html,
281 blaze-markup,
276 blaze-markup,
282 bytestring,
277 bytestring,
278+ cheapskate,
283 cmdargs,
279 cmdargs,
284 containers >= 0.3,
280 containers >= 0.3,
285 directory,
281 directory,
286 Elm,
282 Elm,
287 filemanip,
283 filemanip,
288 filepath,
284 filepath,
285+ highlighting-kate,
289 indents,
286 indents,
290 language-ecmascript >=0.15 && < 1.0,
287 language-ecmascript >=0.15 && < 1.0,
291 language-glsl >= 0.0.2,
288 language-glsl >= 0.0.2,
292 mtl >= 2,
289 mtl >= 2,
293− pandoc >= 1.10,
294 parsec >= 3.1.1,
290 parsec >= 3.1.1,
295 pretty,
291 pretty,
296− scientific,
297 text,
292 text,
298 transformers >= 0.2,
293 transformers >= 0.2,
299 union-find,
294 union-find,
300− unordered-containers,
295+ unordered-containers
301− yaml
302
296
303Test-Suite library-tests
297Test-Suite library-tests
304 Type: exitcode-stdio-1.0
298 Type: exitcode-stdio-1.0
changelog.md+1
@@ -10,6 +10,7 @@
10 * Add Maybe.map
10 * Add Maybe.map
11 * Add --bundle-runtime flag which creates stand-alone Elm programs
11 * Add --bundle-runtime flag which creates stand-alone Elm programs
12 * Error on ambiguious use of imported variables
12 * Error on ambiguious use of imported variables
13+ * Replace dependency on Pandoc with cheapskate+kate
13 * Better architecture for compiler. Uses types to make compilation pipeline
14 * Better architecture for compiler. Uses types to make compilation pipeline
14 safer, setting things up for giving programmatic access to the AST to
15 safer, setting things up for giving programmatic access to the AST to
15 improve editor and IDE support.
16 improve editor and IDE support.
compiler/Generate/Markdown.hs+34−31
@@ -1,39 +1,42 @@
1module Generate.Markdown where
1module Generate.Markdown where
2
2
3−import Text.Pandoc
3+import qualified Cheapskate as CS
4+import qualified Cheapskate.Html as CS
4import qualified Data.Set as Set
5import qualified Data.Set as Set
6+import qualified Data.Text as Text
7+import qualified Text.Blaze.Html.Renderer.String as Blaze
8+import qualified Text.Highlighting.Kate as Kate
9+
10+import Debug.Trace
11+
12+(|>) :: a -> (a -> b) -> b
13+x |> f = f x
5
14
6toHtml :: String -> String
15toHtml :: String -> String
7−toHtml = writeHtmlString writeOptions . readMarkdown readOptions
16+toHtml rawMarkdown =
17+ Text.pack rawMarkdown
18+ |> CS.markdown options
19+ |> CS.walk highlightCode
20+ |> CS.renderDoc
21+ |> Blaze.renderHtml
8
22
9−readOptions =
23+options :: CS.Options
10− def { readerExtensions = elmExtensions
24+options =
11− , readerApplyMacros = False
25+ CS.Options
26+ { CS.sanitize = False
27+ , CS.allowRawHtml = True
28+ , CS.preserveHardBreaks = False
29+ , CS.debug = False
12− }
30+ }
13
31
14−writeOptions =
32+highlightCode :: CS.Block -> CS.Block
15− def { writerExtensions = elmExtensions
33+highlightCode block =
16− , writerHighlight = True
34+ case block of
17− }
35+ CS.CodeBlock (CS.CodeAttr lang _info) src ->
36+ Kate.highlightAs (Text.unpack lang) (Text.unpack src)
37+ |> Kate.formatHtmlBlock Kate.defaultFormatOpts
38+ |> Blaze.renderHtml
39+ |> Text.pack
40+ |> CS.HtmlBlock
18
41
19−elmExtensions :: Set.Set Extension
42+ _ -> block
20−elmExtensions = Set.fromList
21− [ Ext_raw_html
22− , Ext_fenced_code_blocks
23− , Ext_fenced_code_attributes
24− , Ext_backtick_code_blocks
25− , Ext_inline_code_attributes
26− , Ext_markdown_in_html_blocks
27− , Ext_escaped_line_breaks
28− , Ext_fancy_lists
29− , Ext_startnum
30− , Ext_definition_lists
31− , Ext_example_lists
32− , Ext_all_symbols_escapable
33− , Ext_intraword_underscores
34− , Ext_blank_before_blockquote
35− , Ext_blank_before_header
36− , Ext_auto_identifiers
37− , Ext_header_attributes
38− , Ext_implicit_header_references
39− ]
compiler/Type/Type.hs+12−9
@@ -376,10 +376,13 @@ instance Crawl Descriptor where
376
376
377toSrcType :: Variable -> IO T.CanonicalType
377toSrcType :: Variable -> IO T.CanonicalType
378toSrcType var =
378toSrcType var =
379− do desc <- UF.descriptor =<< addNames var
379+ go =<< addNames var
380− srcType <- maybe (backupSrcType desc) termToSrcType (structure desc)
381− return $ maybe srcType (\name -> T.Aliased name srcType) (alias desc)
382 where
380 where
381+ go v = do
382+ desc <- UF.descriptor v
383+ srcType <- maybe (backupSrcType desc) termToSrcType (structure desc)
384+ return $ maybe srcType (\name -> T.Aliased name srcType) (alias desc)
385+
383 backupSrcType desc =
386 backupSrcType desc =
384 case name desc of
387 case name desc of
385 Just v@(Var.Canonical _ x@(c:_))
388 Just v@(Var.Canonical _ x@(c:_))
@@ -394,22 +397,22 @@ toSrcType var =
394 termToSrcType term =
397 termToSrcType term =
395 case term of
398 case term of
396 App1 a b -> do
399 App1 a b -> do
397− a' <- toSrcType a
400+ a' <- go a
398− b' <- toSrcType b
401+ b' <- go b
399 case a' of
402 case a' of
400 T.App f args -> return $ T.App f (args ++ [b'])
403 T.App f args -> return $ T.App f (args ++ [b'])
401 _ -> return $ T.App a' [b']
404 _ -> return $ T.App a' [b']
402
405
403− Fun1 a b -> T.Lambda <$> toSrcType a <*> toSrcType b
406+ Fun1 a b -> T.Lambda <$> go a <*> go b
404
407
405− Var1 a -> toSrcType a
408+ Var1 a -> go a
406
409
407 EmptyRecord1 -> return $ T.Record [] Nothing
410 EmptyRecord1 -> return $ T.Record [] Nothing
408
411
409 Record1 tfields extension -> do
412 Record1 tfields extension -> do
410− fields' <- traverse (mapM toSrcType) tfields
413+ fields' <- traverse (mapM go) tfields
411 let fields = concat [ map ((,) name) ts | (name,ts) <- Map.toList fields' ]
414 let fields = concat [ map ((,) name) ts | (name,ts) <- Map.toList fields' ]
412− ext' <- dealias <$> toSrcType extension
415+ ext' <- dealias <$> go extension
413 return $ case ext' of
416 return $ case ext' of
414 T.Record fs ext -> T.Record (fs ++ fields) ext
417 T.Record fs ext -> T.Record (fs ++ fields) ext
415 T.Var _ -> T.Record fields (Just ext')
418 T.Var _ -> T.Record fields (Just ext')
runtime/Render/Collage.js+1−1
@@ -301,7 +301,7 @@ function nodeStepper(w,h,div) {
301 : (Render.update(kid, kid.oldElement, elem), kids[i]);
301 : (Render.update(kid, kid.oldElement, elem), kids[i]);
302
302
303 node.style.position = 'absolute';
303 node.style.position = 'absolute';
304− node.style.opacity = alpha * form.alpha;
304+ node.style.opacity = alpha * form.alpha * elem.props.opacity;
305 addTransform(node.style, makeTransform(w, h, form, matrices));
305 addTransform(node.style, makeTransform(w, h, form, matrices));
306 node.oldElement = elem;
306 node.oldElement = elem;
307 ++i;
307 ++i;
runtime/Render/Element.js+15−6
@@ -3,9 +3,12 @@ ElmRuntime.Render.Element = function() {
3'use strict';
3'use strict';
4
4
5var Utils = ElmRuntime.use(ElmRuntime.Render.Utils);
5var Utils = ElmRuntime.use(ElmRuntime.Render.Utils);
6−var newElement = Utils.newElement, colorToCss = Utils.colorToCss,
6+var newElement = Utils.newElement;
7+var colorToCss = Utils.colorToCss;
8+var addTransform = Utils.addTransform;
7− addTransform = Utils.addTransform, removeTransform = Utils.removeTransform,
9+var removeTransform = Utils.removeTransform;
8− fromList = Utils.fromList, eq = Utils.eq;
10+var fromList = Utils.fromList;
11+var eq = Utils.eq;
9
12
10function setProps(elem, node) {
13function setProps(elem, node) {
11 var props = elem.props;
14 var props = elem.props;
@@ -253,7 +256,9 @@ function rawHtml(elem) {
253 return div;
256 return div;
254}
257}
255
258
259+function render(elem) {
256−function render(elem) { return setProps(elem, makeElement(elem)); }
260+ return setProps(elem, makeElement(elem));
261+}
257function makeElement(e) {
262function makeElement(e) {
258 var elem = e.element;
263 var elem = e.element;
259 switch(elem.ctor) {
264 switch(elem.ctor) {
@@ -267,8 +272,12 @@ function makeElement(e) {
267}
272}
268
273
269function update(node, curr, next) {
274function update(node, curr, next) {
275+ if (node.tagName === 'A') {
270− if (node.tagName === 'A') { node = node.firstChild; }
276+ node = node.firstChild;
277+ }
278+ if (curr.props.id === next.props.id) {
271− if (curr.props.id === next.props.id) return updateProps(node, curr, next);
279+ return updateProps(node, curr, next);
280+ }
272 if (curr.element.ctor !== next.element.ctor) {
281 if (curr.element.ctor !== next.element.ctor) {
273 node.parentNode.replaceChild(render(next),node);
282 node.parentNode.replaceChild(render(next),node);
274 return true;
283 return true;