Skip to content

Instantly share code, notes, and snippets.

@joseanpg
Last active December 16, 2015 10:39
Show Gist options
  • Save joseanpg/5421222 to your computer and use it in GitHub Desktop.
Save joseanpg/5421222 to your computer and use it in GitHub Desktop.
Elm example
//http://elm-lang.org/edit/examples/Reactive/Position.elm
//https://github.com/evancz/Elm/blob/master/elm/elm-runtime-0.7.2.js
try {
if (Elm.Main) throw new Error("Module name collision, 'Main' is already defined.");
Elm.Main = function () {
var $op = {};
for (Elm['i'] in Elm) {
eval('var ' + Elm['i'] + '=Elm[Elm.i];');
}
try {
if (!(Elm.Prelude instanceof Object)) throw new Error('module not found');
} catch (e) {
throw new Error("Module 'Prelude' is missing. Compile with --make flag or load missing module in a separate JavaScript file.");
}
var hiddenVars = {};
for (Elm['i'] in Elm.Prelude) {
if (hiddenVars[Elm['i']]) continue;
eval('var ' + Elm['i'] + ' = Elm.Prelude[Elm.i];');
}
var main_0 = lift(asText)(Mouse.position);
return {
$op: {},
main: main_0
};
}();
Elm.main = function () {
return Elm.Main.main;
};
} catch (e) {
Elm.main = function () {
var msg = ('<br/><h2>Your browser may not be supported. Are you using a modern browser?</h2>' + '<br/><span style="color:grey">Runtime Error in Main module:<br/>' + e + '</span>');
document.body.innerHTML = Elm.Text.monospace(msg);
throw e;
};
}
Dispatcher.initialize()
//http://elm-lang.org/edit/examples/Reactive/Position.elm
//https://github.com/evancz/Elm/blob/master/elm/elm-runtime-0.7.2.js
Elm.Main = function () {
var $op = {};
for (Elm['i'] in Elm) {
eval('var ' + Elm['i'] + '=Elm[Elm.i];');
}
var hiddenVars = {};
for (Elm['i'] in Elm.Prelude) {
if (hiddenVars[Elm['i']]) continue;
eval('var ' + Elm['i'] + ' = Elm.Prelude[Elm.i];');
}
var main_0 = lift(asText)(Mouse.position);
return {
$op: {},
main: main_0
};
}();
Elm.main = function () {
return Elm.Main.main;
};
Dispatcher.initialize()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment