Skip to content

Instantly share code, notes, and snippets.

View miwillhite's full-sized avatar

Matthew Willhite miwillhite

View GitHub Profile

Keybase proof

I hereby claim:

  • I am miwillhite on github.
  • I am mwillhite (https://keybase.io/mwillhite) on keybase.
  • I have a public key ASAvBE9hF9gAxNjmuh0Ixd5nS7rNvLyZC8aWYzCroFR5tAo

To claim this, I am signing this object:

@miwillhite
miwillhite / validation.js
Last active December 3, 2020 00:50
A naïve Validation ADT implementation in JS vs ReasonML vs PureScript
/*
JavaScript
There are 2 files.
1) The ADT definition.
Here we define the data constructors, their properties and the
implemenations (or "instances") of the various methods, in this
case "concat".
@miwillhite
miwillhite / gist:04ac6ccf9abf9bac3ec398e7512adf20
Created March 12, 2018 15:38
TypeError: Cannot read property 'forEach' of undefined
Node {
type: 'BlockStatement',
start: 1059,
end: 1171,
loc:
SourceLocation {
start: Position { line: 32, column: 50 },
end: Position { line: 40, column: 1 } },
range: [ 1059, 1171 ],
body:
// :: ReactComponent -> ReactComponent -> ReactComponent
const concatR = A => B =>
({ ...props, children }) =>
<>
<A { ...props } { ...children } />
<B { ...props } { ...children } />
</>
// :: ReactComponent
const EmptyComponent = <></>;
import { async, hold } from 'most-subject';
import reducer from './reducer';
const initialState = {};
// :: AsyncSubject
const store = hold(1, async());
// :: Action -> ()
export const next = store.next.bind(store);
// :: AsyncSubject State
export const state = store.scan(reducer, initialState);
@miwillhite
miwillhite / articles.md
Last active April 10, 2023 22:40
Functional JavaScript (and other)
@miwillhite
miwillhite / index.js
Last active October 31, 2016 17:34
requirebin sketch
const daggy = require('daggy');
const R = require('ramda');
const Future = require('fluture');
const S = require('sanctuary');
const { Left, Right, Either } = S;
const Answer = daggy.taggedSum({
Pure: ['value'],
Addressable: ['street', 'city', 'postal_code', 'state'], // Address
Contactable: ['contact_uid'], // Participant and Relationship
var store = new TaskStore(reducer, actions.init({
tasks: {
incomplete: incompleteTasks,
complete: completedTasks,
},
}));
store.state.observe(function (state) { console.log(state) });
import * as fs from 'fs';
import {
always, append, apply, compose, complement, equals, flip, head, ifElse, inc, indexOf,
length, lift, lt, map, range, reduce, reduced, reject, split, sum, tail, take, test
} from 'ramda';
// Get the words list and create an array, rejecting anything with apostrophes
const words = compose(
reject(test(/'/)),
split('\n'),
# In my init/setup
// Register the header
[self.collectionView registerClass:[DummyView class]
forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:kJJUserJujuLibraryHeaderIdentifier];
# This is being called
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout