For educational reasons I've decided to create my own CA. Here is what I learned.
Lets get some context first.
{ | |
"countries": [ | |
{ | |
"country": "Afghanistan", | |
"states": ["Badakhshan", "Badghis", "Baghlan", "Balkh", "Bamian", "Daykondi", "Farah", "Faryab", "Ghazni", "Ghowr", "Helmand", "Herat", "Jowzjan", "Kabul", "Kandahar", "Kapisa", "Khost", "Konar", "Kondoz", "Laghman", "Lowgar", "Nangarhar", "Nimruz", "Nurestan", "Oruzgan", "Paktia", "Paktika", "Panjshir", "Parvan", "Samangan", "Sar-e Pol", "Takhar", "Vardak", "Zabol"] | |
}, | |
{ | |
"country": "Albania", | |
"states": ["Berat", "Dibres", "Durres", "Elbasan", "Fier", "Gjirokastre", "Korce", "Kukes", "Lezhe", "Shkoder", "Tirane", "Vlore"] | |
}, |
Loop = (value, {x, y}) => ({ | |
value: value, | |
cata: mapping => | |
x > y | |
? value | |
: Loop(mapping(value, x), {x: x + 1, y}) | |
.cata(mapping) | |
}); | |
console.log( |
o = { user: { name: 'foo' } } | |
const get = key => obj => obj[key] | |
const set = key => (x, obj) => | |
({ ...obj, [key]: x }) | |
Identity = v => ({ | |
value: v, |
// base | |
const Valid = x => ({ | |
map: f => Valid(f(x)), | |
chain: f => f(x), | |
bimap: ({valid}) => Valid(valid(x)), | |
cata: ({valid}) => valid(x) | |
}) | |
const Wrong = x => ({ |
// Setoid | |
a.equals(a) === true // reflexivity | |
a.equals(b) === b.equals(a) // summetry | |
a.equals(b) && b.equals(c) == q.equals(c) // transitivity | |
// Ord | |
// must also implement the Setoid | |
a.lte(b) || b.lte(a) === true // totality |
CREATE TABLE accounts( | |
id serial PRIMARY KEY, | |
name VARCHAR(256) NOT NULL | |
); | |
CREATE TABLE entries( | |
id serial PRIMARY KEY, | |
description VARCHAR(1024) NOT NULL, | |
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0), | |
-- Every entry is a credit to one account... |
When receiving JSON data from other resources(server API etc), we need Json.Decode to convert the JSON values into Elm values. This gist let you quickly learn how to do that.
I like to follow working example code so this is how the boilerplate will look like:
import Graphics.Element exposing (Element, show)
import Task exposing (Task, andThen)
import Json.Decode exposing (Decoder, int, string, object3, (:=))
import Http
import Html | |
main = Html.text "Hello World" |
function ListController ( Service, $mdDialog ) { | |
const vm = this; | |
vm.list = true; | |
vm.MODULE_NAME = MODULE_NAME; | |
vm.PATH = MODULE_NAME.toLowerCase(); | |
const hiddenFields= [ | |
'active' | |
, 'password' | |
, 'automaticLogin' |