Skip to content

Instantly share code, notes, and snippets.

View xaviervia's full-sized avatar

Fernando Via Canel xaviervia

View GitHub Profile
@xaviervia
xaviervia / directCell.js
Created February 12, 2017 09:43
2017-02-11
const c = directCell( x => console.log('a'))
c(1, 1) // nothing
c(1, 0) // 'a'
effect( next => cell( state => ).pipe(cell(x => y)) void ))
const a = Arrow( id )
a.product(a).product(a)([1, [2, 3]])
@xaviervia
xaviervia / README.md
Last active February 5, 2017 23:43
babel transform to trace function calls, try 1
  • Open https://astexplorer.net/
  • Set it to JavaScript if it's not
  • Set it to babylon6
  • Paste the source.js code in the top left pane
  • In the "Transform" menu on the top select babel6
  • Copy the transform.js code in the bottom left page
import { createType } from './type'
import type {Data, Type, TypeChecker} from './type'
type IncT = Type<'Inc', number>
type DecT = Type<'Dec', number>
type ResetT = Type<'Reset', number>
type WhatT = Type<'What', number>
const IncAction: Data<IncT, number> = createType('Inc')
const DecAction: Data<DecT, number> = createType('Dec')
const ResetAction: Data<ResetT, number> = createType('Reset')
const createType = name => {
const of = x => Object.freeze({
'@@type': name,
fold: f => f(x),
map: f => of(f(x)),
inspect: () => `${name}(${x})`
})
return {of}
}
@xaviervia
xaviervia / CustomCheckbox-withUncontrolledProp.js
Last active February 3, 2017 16:57
How we almost reinvent the Redux Store - III
withUncontrolledProp({
prop: 'checked',
defaultProp: 'autoChecked',
handlers: {
onClick: (previousProps) => !previousProps.checked
}
})(CustomCheckbox)
@xaviervia
xaviervia / CustomCheckboxStateful.js
Created February 1, 2017 15:16
How we almost reinvent the Redux Store - II
class CustomCheckbox extends Component {
constructor () {
super()
this.state = {
checked: false
}
}
componentWillMount () {
@xaviervia
xaviervia / CustomCheckbox.js
Last active February 1, 2017 14:50
How we almost reinvent the Redux Store
function CustomCheckbox ({ onClick, checked }) {
return <div onClick={onClick}>
{checked ? 'Checked' : 'Not checked'}
</div>
}
@xaviervia
xaviervia / cell-try-oh-so-many.js
Last active January 29, 2017 19:02
2017-01-28 notes
const Cell = f => {
const _c = Arrow((x, [h, t]) => {
const fx = f(x)
cond(
[() => fx === h, Left([h, t])]]
[true, Right([fx, t])]]
)
})
@xaviervia
xaviervia / Makefile
Created January 19, 2017 08:08
My Makefile for Github pages
# Assumes that:
# - You are on the master branch
# - Your dist npm task puts things into the dist/ folder
gh-pages:
-git checkout -b gh-pages
git checkout gh-pages
git merge master
npm run dist
cp dist/* .
git add . && git commit -m "♻️ 📄"
@xaviervia
xaviervia / README.md
Last active January 15, 2017 19:55
2017-01-15 notes
  • "Laws" test suite: run flowtyped functions to verify that a "monoid" (for example) really follows the laws for its empty and concat operations.