Skip to content

Instantly share code, notes, and snippets.

@gcanti
gcanti / HKT.js
Last active October 27, 2018 06:56
HKTs in Flow
// @flow
// type-level dictionary URI -> type constructor
export type URI2HKT<U, L, A> = {
Identity: Identity<A>
// other type constructors here...
// Option: Option<A>,
// Either: Either<L, A>,
// Foo: Foo<U, L, A>
}
@evancz
evancz / data-interchange.md
Last active October 31, 2024 12:01
Why do I have to write JSON decoders in Elm?

A vision for data interchange in Elm

How do you send information between clients and servers? What format should that information be in? What happens when the server changes the format, but the client has not been updated yet? What happens when the server changes the format, but the database cannot be updated?

These are difficult questions. It is not just about picking a format, but rather picking a format that can evolve as your application evolves.

Literature Review

By now there are many approaches to communicating between client and server. These approaches tend to be known within specific companies and language communities, but the techniques do not cross borders. I will outline JSON, ProtoBuf, and GraphQL here so we can learn from them all.

@dk00
dk00 / 0.0.1-2.ls
Last active January 27, 2017 12:07
Livescript AST to babel AST converter
``import * as types from 'babel-types'``
function L
start: line: it.first_line, column: it.first_column
end: line: it.last_line, column: it.last_column
[none = [] empty = {} REF = 1 ASSIGN = 2 DECL = 4 PARAM = 8]
function pass => it
type-name = (.constructor.display-name)
function t node, scope
@srdjan
srdjan / 100+ different counter apps...
Last active May 6, 2024 05:13
100+ different js counter apps...
100+ different js counter apps...
@gcanti
gcanti / flow_tlp1.md
Last active April 6, 2018 19:34
Type level programming with Flow, encoding a finite state machine
// @flow

// based on State Machines All The Way Down
// An Architecture for Dependently Typed Applications
// https://eb.host.cs.st-andrews.ac.uk/drafts/states-all-the-way.pdf
// by Edwin Brady

//
// finite state machine
@Avaq
Avaq / combinators.js
Last active September 26, 2024 18:53
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
request = require 'superagent-bluebird-promise'
Promise = require 'bluebird'
history = require '../history'
module.exports = class RelayNetworkLayer
constructor: (options = {}) ->
@token = options.token
@host = options.host
sendMutation: (requests) ->
@evanrs
evanrs / rewriting-history-with-predicates.md
Last active November 4, 2015 07:14
Rewriting history with predicates (Reactive 2015 lightning talk proposal)

This is a proposal for a lightning talk I would give at the Reactive 2015 conference.

NOTE: If you like it, put a star ⭐ on it—the number of stars decides if it makes the cut!

Rewriting history with predicates

Redux provides a simple pattern for managing application state. As demonstrated in Dan Abramov's talk following this pattern lets you painlessly implement simple undo and time travel. By keeping a history of actions, and reducing a subset

@lambdahands
lambdahands / _readme.md
Created September 28, 2015 17:09
FlowType and CSS Modules

Huh?

So basically FlowType doesn't know about CSS Modules, a really handy way of dealing with the plagues of CSS in codebases (global variables and dependency wackiness mainly).

What WebPack allows us to do is "require" CSS files and use their class names:

import styles from "my_styles.css";
import React from "react";
@teropa
teropa / reactive2015_gol.md
Created September 24, 2015 15:56
ClojureScript Game of Life - Reactive 2015 Lightning Talk Proposal

In my proposed lightning talk for the Reactive Conference, I'll create Conway's Game of Life in ClojureScript, and I'll do it in five minutes. I'll use an interactive programming workflow enabled by Figwheel. Each piece will be added into the running application without reloading the page.

If you want to see a little cellular lifeform spawn out of nothing into an running web browser window, I'd appreciate it if you starred this Gist!

Cheers,

(@teropa)