Skip to content

Instantly share code, notes, and snippets.

case pet of
Fish fish -> fish.swim
Bird bird -> bird.fly
a = 1;
a = a + 2;
a = a * 3; // Gives 9
// while, inverting the order of
// the 2nd and 3rd line:
a = 1;
a = a * 3;
a = a + 2; // Gives 5
if (isFish(pet)) {
pet.swim();
} else {
pet.fly();
}
function isFish(pet: Fish | Bird): pet is Fish {
return (pet as Fish).swim !== undefined;
}
module Form.Example exposing (..)
import Form.Key
type alias ValidationMessage =
String
type alias EntityId =
module Main exposing (main)
import Browser
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
init = { a = "1", b = "2" }
type Msg = ChangeA String | ChangeB String
@lucamug
lucamug / elm-logo-in-terminal.js
Created June 19, 2019 04:44
Elm logo in terminal
const chalk = require('chalk')
logoElm = [
'ggggcccc',
'bggggccc',
'bboooocc',
'bbbooggc',
'bbbxgggo',
'bbxccgoo',
'bxccccoo',
#!/usr/local/bin/node
// From a gist of Jinjor: https://gist.github.com/jinjor/cce51986afa422a3e38befebe091ead2
const fs = require("fs");
const childProcess = require("child_process");
childProcess.exec("./node_modules/.bin/elm-analyse", (e, out) => {
let file;
let unusedImports = {};
let unusedAliases = {};
for (let line of out.split("\n")) {
<div id="app">
<div v-for="product in products">
<input type="number" v-model="product.quantity">
<button @click="product.quantity += 1">
Add 1
</button>
{{ product.name }}
</div>
<p>Total Inventory: {{ totalProducts }}</p>
<p>Quantities: {{products.map(function(p){return p.quantity})}}</p>
<div id="app"></div>
<script src="js/elm.v.1.js"></script>
<script>
Elm.Main.init({
node: document.getElementById("app"),
flags: {
url: "https://api.myjson.com/bins/74l63"
}
});
</script>