Markdown Interpolation

330 views
Skip to first unread message

Evan Czaplicki

unread,
Oct 25, 2013, 11:44:24 AM10/25/13
to elm-d...@googlegroups.com
I just implemented this on the markdown branch. You can embed arbitrary expressions in markdown using double curly braces. (please no bug reports yet, I implemented it today as an experiment)

Here are some examples you can look through (and run once you move to the new branch).

Let me know what you think of this. I feel like I should add more restrictions, but maybe I am being overcautious.

Joseph Collard

unread,
Oct 25, 2013, 12:53:19 PM10/25/13
to elm-d...@googlegroups.com
At a glance, this looks great! I will rewrite my directory page over the weekend using this (scrapping my css flag) and let you know how it goes.

Joe


--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Evan Czaplicki

unread,
Oct 25, 2013, 1:58:11 PM10/25/13
to elm-d...@googlegroups.com
Okay, very glad to hear that :) I am thinking of how to nicely allow a limited set of style flags for a markdown block. I am imagining a record that lets you set leading, typeface, etc. but I have not been able to think of an acceptable syntax for this yet.

One way may be to change the type of markdown blocks to TextBlock and then have something like this:

format : TextStyle -> TextBlock -> Element

main = format { defaultStyle | leading <- 2 } [markdown| hats on racks on racks |]

This seems alright, but I feel like it could be better. Any other ideas?

Joseph Collard

unread,
Oct 25, 2013, 2:37:25 PM10/25/13
to elm-d...@googlegroups.com
I think it should be:

format : [TextStyle] -> TextBlock -> Element

where TextStyle is something like:

data TextStyle = Bold | Italic | FontSize Int | ... 

My $0.02

Joe

Joseph Collard

unread,
Oct 25, 2013, 3:21:41 PM10/25/13
to elm-d...@googlegroups.com
On a second look, the way you had it is fine. I didn't realize TextStyle was a record.

Joe

Jeff Smits

unread,
Oct 26, 2013, 6:06:41 AM10/26/13
to elm-discuss
Looks great Evan :)
I think formatting it like you propose is fine. But would the expected behaviour be that this formatting overrides that of interpolated values?

sh...@sheeo.dk

unread,
Oct 26, 2013, 2:07:32 PM10/26/13
to elm-d...@googlegroups.com
I love this feature -- really makes Elm a potential killer language for writing interactive articles.

Evan Czaplicki

unread,
Oct 26, 2013, 2:07:29 PM10/26/13
to elm-d...@googlegroups.com
Thanks :) How I'm thinking of it, it would not override anything. The goal of this record would be to specify text layout things that do not belong at the level of text. Currently my list of things that belong in the record include:
  • line spacing
  • fonts for paragraphs, headers, and code
  • syntax highlighters for code blocks (perhaps this could also be a record that's easy to mess around with)
  • padding for paragraphs
I think margins and borders do not belong here. They can be done with embedded elements. Are there any other things that maybe belong in this group?

Evan Czaplicki

unread,
Oct 26, 2013, 2:26:26 PM10/26/13
to elm-d...@googlegroups.com
sheeo, that's a really great way of framing it! :D

Perhaps this also makes Elm closer to the "traditional" workflow. The words people can create markdown blocks. The designers can create widgets using only Elements and Forms (way easier than CSS and HTML) resulting in pure functions from data to graphics. The coder can work on the diagrams and interaction. I'm not sure how much I believe in this division of labour in general (coders write better code), but it seems plausible.


--

Alex Shroyer

unread,
Oct 28, 2013, 11:33:53 AM10/28/13
to elm-d...@googlegroups.com
Would this be a way to get Tangle-like interaction in a document?  Would the interpolated Element/Form be able to tell if I click/drag it?

Evan Czaplicki

unread,
Oct 28, 2013, 12:19:25 PM10/28/13
to elm-d...@googlegroups.com
Yes, as long as drags can be detected on Elements and Forms. So the hoverable API would probably make this possible, like this. (looks like there may be a display bug with hoverable elements.)

Evan Czaplicki

unread,
Oct 29, 2013, 10:35:50 AM10/29/13
to elm-d...@googlegroups.com
markdown branch is now merged into the dev branch. Go to the dev branch to use this feature!

Alex Shroyer

unread,
Oct 29, 2013, 11:28:41 AM10/29/13
to elm-d...@googlegroups.com
Noob Git question: How does one "go to" or "move to" a particular branch of Elm?
Is it just git clone <git clone url> ?

Jeff Smits

unread,
Oct 29, 2013, 11:30:46 AM10/29/13
to elm-discuss
if you have cloned the git repo, use git checkout <branchname>
in this case git checkout dev

On Tue, Oct 29, 2013 at 4:28 PM, Alex Shroyer <ashr...@gmail.com> wrote:
Noob Git question: How does one "go to" or "move to" a particular branch of Elm?
Is it just git clone <git clone url> ?

--

Evan Czaplicki

unread,
Oct 29, 2013, 11:53:45 AM10/29/13
to elm-d...@googlegroups.com
Yeah, so it'd be this process:

cd Elm
git checkout dev
cabal install

You can also use the following command to see what branch you are on:

git status

I use the "GitHub for Mac" application for most things. It is nice and covers all of the basics. You can learn the command line things as they become necessary.

Alex Shroyer

unread,
Oct 29, 2013, 12:05:20 PM10/29/13
to elm-d...@googlegroups.com
Thanks Jeff and Evan!

Joseph Collard

unread,
Nov 14, 2013, 8:41:11 PM11/14/13
to elm-d...@googlegroups.com
I am just now trying to use the markdown interpolation but every time I use it, the output for the interpolation is {{ ... }}. Any idea what I might be doing wrong?

Joe

Evan Czaplicki

unread,
Nov 15, 2013, 7:02:42 AM11/15/13
to elm-d...@googlegroups.com
Which branch are you on?

Joseph Collard

unread,
Nov 15, 2013, 1:19:44 PM11/15/13
to elm-d...@googlegroups.com
I was on the dev branch. However, I just did a pull and recompiled and it seems to be working correctly now.

Joe

Joseph Collard

unread,
Nov 15, 2013, 1:44:03 PM11/15/13
to elm-d...@googlegroups.com
However, it should be noted that the latest dev branch breaks the Sprite library.

AnimationTest using the latest elm-runtime.js can be found here: 

Evan Czaplicki

unread,
Nov 18, 2013, 12:18:01 PM11/18/13
to elm-d...@googlegroups.com
I think I know the bug you are seeing. I think it showed up in Chrome 31. They changed the behavior of caching of images in JS. When you create a new Image(url) it no longer caches the result, so the onload event gets called every time a new image is created. This can actually cause an infinite loop in the renderer and mess things up pretty catastrophically.

I think this means we need to implement some sort of image url cache to deal with this.

Alex Shroyer

unread,
Nov 26, 2013, 4:41:02 PM11/26/13
to elm-d...@googlegroups.com
Just tried to build the dev branch (using the command:  cabal install --force-reinstalls) and got this error:

[13 of 48] Compiling Parse.Helpers    ( compiler/Parse/Helpers.hs, dist/build/Parse/Helpers.o )

compiler/Parse/Helpers.hs:17:19:
    Module `Text.Read' does not export `readMaybe'
cabal: Error: some packages failed to install:
Elm-0.10.0.2 failed during the building phase. The exception was:
ExitFailure 1

Suggestions?  I'm using Ubuntu 12.10 on ARM have had some issues with Haskell packages in the past which were solved with additional build constraints.

Mads Flensted-Urech

unread,
Nov 26, 2013, 4:44:44 PM11/26/13
to elm-d...@googlegroups.com
I see the same thing, also on ubuntu 12.04.

Strange thing is that a seach on hoogle shows no (relevant) hits for readMaybe

Evan Czaplicki

unread,
Nov 26, 2013, 10:26:50 PM11/26/13
to elm-d...@googlegroups.com
Can you check to see if the relevant library had a new release recently? I don't know if hoogle searches "old" APIs.

Mads Flensted-Urech

unread,
Dec 12, 2013, 9:47:43 AM12/12/13
to elm-d...@googlegroups.com
This problem is related to GHC version. I was building with 7.4.2, but the above API change requires the newer base package that is part of 7.6.x . 

So one of the packages that Elm depend on depend on a newer version of base. This shows how important it is that a package manager at least manages dependencies to the base/core correctly, i.e. cabal should be choosing the highest possible version within the boundaray of the current base/core. Something think about in elm-get.

I am currently working on some scripts to setup docker containers with a working version of ghc and building different version of elm. I'll post separately about that once it works.




Evan Czaplicki

unread,
Dec 12, 2013, 12:29:29 PM12/12/13
to elm-d...@googlegroups.com
I switched out that dependency in the dev branch so it no longer needs readMaybe. Does that resolve the issue for you guys? Sorry for the trouble!

Alex Shroyer

unread,
Dec 12, 2013, 11:52:06 PM12/12/13
to elm-d...@googlegroups.com
Well dang.  

[47 of 47] Compiling Main             ( compiler/Compiler.hs, dist/build/elm/elm-tmp/Main.o )
Linking dist/build/elm/elm ...
Custom build step: compiling standard libraries
elm: internal error: setNumCapabilities: not supported in the non-threaded RTS
    (GHC version 7.4.2 for arm_unknown_linux)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Good news is it appears to be an ARM issue rather than an Elm issue.

Mads Flensted-Urech

unread,
Dec 13, 2013, 3:01:07 AM12/13/13
to elm-d...@googlegroups.com
I get this one too in 7.4.2 (64bit on Intel). Googling this changeset shows up. Will have to check why the RTS is not configured for multithreading, if I understand the error correctly.

Mads Flensted-Urech

unread,
Dec 13, 2013, 3:16:44 AM12/13/13
to elm-d...@googlegroups.com
Ok - found it. You need to build with -threaded option to ghc:

cabal build --ghc-option=-threaded

In researching this I fond it strange that I could not search for either setNumCapabilities or getNumProcessors on hoogle to found the module they belonged to. Here Elm doc's are much better.

Anyway found the solution here


Alex Shroyer

unread,
Dec 13, 2013, 9:57:28 AM12/13/13
to elm-d...@googlegroups.com
Thanks Mads, you are awesome.  Quick question, should this command:
cabal build --ghc-option=-threaded 
be executed in my new (dev branch checked out) Elm/ directory?

Mads Flensted-Urech

unread,
Dec 13, 2013, 10:04:48 AM12/13/13
to elm-d...@googlegroups.com
You are welcome. Yes - here is the full list of "install" commands that currently work for me (using ghc 7.4) when I start from a clean setup:

cd Elm
cabal update
cabal install --only-dependencies
cabal configure
cabal build --ghc-option=-threaded
cabal install


Evan Czaplicki

unread,
Dec 13, 2013, 12:32:30 PM12/13/13
to elm-d...@googlegroups.com
Hmm, I think I am responsible for this. I took off the -O2 and -threaded flags from the .cabal file to try to bring down install times. Perhaps that was misguided in the first place. I'll add them back and ping this thread when it's added. Would you mind trying to install again after that to see if this is resolved?
--
Sent from Gmail Mobile

Mads Flensted-Urech

unread,
Dec 13, 2013, 12:41:13 PM12/13/13
to elm-d...@googlegroups.com

No problem, can easily re-test

--

Alex Shroyer

unread,
Dec 13, 2013, 2:00:35 PM12/13/13
to elm-d...@googlegroups.com, ma...@flensted-urech.dk
I'll definitely re-install to test, Evan.  I want to play with markdown and also get the new and improved compiler error messages. :)

Evan Czaplicki

unread,
Dec 13, 2013, 2:18:10 PM12/13/13
to elm-d...@googlegroups.com, Mads Flensted-Urech
Okay, it should be updated. Let me know if the issue is resolved!

Unfortunately though, I decided to wait until later for the markdown interpolation, so it is "turned off" in dev at the moment. I was thinking of making a separate branch for it, but I did not do that yet.


On Fri, Dec 13, 2013 at 11:00 AM, Alex Shroyer <ashr...@gmail.com> wrote:
I'll definitely re-install to test, Evan.  I want to play with markdown and also get the new and improved compiler error messages. :)

--

Mads Flensted-Urech

unread,
Dec 13, 2013, 2:49:28 PM12/13/13
to elm-d...@googlegroups.com
Yes - now it works with just "cabal build"

With regards to ghc version, is it you target that Elm should compile on both 7.4 and 7.6 ?

Alex Shroyer

unread,
Dec 13, 2013, 5:08:37 PM12/13/13
to elm-d...@googlegroups.com
Working for me on ARM as well.  Thank you Evan and Mads!

Evan Czaplicki

unread,
Dec 13, 2013, 6:36:35 PM12/13/13
to elm-d...@googlegroups.com
Mads, not explicitly, but I'd like to be as permissive as possible. My main goal is to minimize the amount of install crap that people have to go through (cabal hell, etc.) and I don't think I need any 7.6 features. I stopped using multiway ifs because of this.

Glad it's working!
Reply all
Reply to author
Forward
0 new messages