This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if $(which elm) $* | |
then | |
echo '{"type":"compile-errors","errors":[]}' >&2 | |
else | |
touch $0 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function camelize (str) { | |
let parts = str.replace(/_/g, ' ').toLowerCase().split(/\W+/) | |
.reduce(function (sum, s) { | |
if (typeof sum === 'string') sum = [sum] | |
if (sum[0]) return [...sum, s[0].toUpperCase() + s.slice(1)] | |
return [s] | |
}) | |
return (typeof parts === 'string' ? parts : parts.join('')) | |
} | |
console.log(`module Env exposing (..) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ICal exposing | |
( VAlarmAction(..) | |
, VAlarmTrigger(..) | |
, VCalendar(..) | |
, VEvent(..) | |
, VEventProp(..) | |
, VEventStatusValue(..) | |
, eventPropString | |
, eventString | |
, string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var waitall = { | |
defer: [], | |
final: null | |
} | |
// will make sure to call `waitall.final` when all `waitall.defer` has cleared | |
function defer (fn) { | |
waitall.defer.push(fn) | |
return function (...args) { | |
var result = fn(...args) |
- Elm is not a frontend framework.
- Elm is neither V in MVC, nor MV in MVC, nor even MVC itself.
- You don't assemble libraries and configure options to make Elm do what you want.
Elm is a language. You write programs with it.
But instead of providing a regular main
function to run, Elm wants you to write at least 2 parts to run your program: init
and update
. This is my pseudo code for your init
and update
plugs into Elm runtime:
let [globalState, cmd] = init(optionFlags)
Scenario: Given a cookie string (which may be absent), parse and return a User record/struct
Often we'd write functions where arguments are "nullable", aka *string
in Go, aka a Maybe
in Elm
-- function `userFromCookie` with parameter type `Maybe String` return type `User`
userFromCookie1 : Maybe String -> User
userFromCookie1 maybeString =
case maybeString of
Nothing ->
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module AWS exposing (Config, HttpRequest, Service(..), httpTask, sign__) | |
import Base16 | |
import Crypto.HMAC | |
import Crypto.Hash | |
import DateFormat | |
import Http | |
import Json.Encode | |
import Task exposing (Task) | |
import Time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-| Maybe like how data from remote server can be modelled with 4 states `krisajenkins/remotedata` | |
perhaps form input can be modelled similarly too, giving us a convenient way to work with them | |
`err` stores validation errors for the form values, e.g. Dict String String | |
`a` stores the raw value from user input, e.g. Dict String String | |
`b` is the data type that we expect to wield if `a` is valid, e.g. API.CreateUser.Input | |
-} | |
type FormData err a b | |
= NotValid a err |