This file contains hidden or 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
| // Similar to Future but contains a series of future values | |
| const {I, compose} = require('../util') | |
| // ( -> a) -> Stream a | |
| function _Stream(pusher) { | |
| this.push = pusher || I | |
| this['@@type'] = "Stream" | |
| } | |
| const Stream = pusher => new _Stream(pusher) |
This file contains hidden or 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 FT = require('myFunctionalTestFramework'); | |
| module.exports = FT.suite("Array", { | |
| "is a functor": (it)=> { | |
| var ar = [1] | |
| return it.all( | |
| it('returns array with value incremented').isLike([2], ar.map(x=>x+1)) | |
| , it('returns new array').isnt(ar, ar.map(a => a)) | |
| ) | |
| } | |
| }) |
This file contains hidden or 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
| --- | |
| extends: "eslint:recommended" | |
| root: true | |
| env: | |
| es6: true | |
| browser: true | |
| node: true | |
| ecmaFeatures: | |
| modules: false | |
| rules: |
This file contains hidden or 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
| // There's something elegant about this... | |
| const foo = (bar, baz) => Object.assign({}, baz, {bar}) |
Dependency Inversion Principle (DIP) is a design pattern popular in Object Oriented Programming but it's not alien to functional programming. Parameterizing dependencies is actually critical to maintaining functional purity--one of the most important aspects of FP.
While special dependency injection frameworks are sometimes used, a similar effect can be achieved using partial application.
This file contains hidden or 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
| [alias] | |
| staged = diff --staged | |
| br = branch | |
| st = status | |
| co = checkout | |
| cod = checkout develop | |
| md = merge develop | |
| cb = checkout --track -b | |
| ci = commit | |
| ca = commit --amend |
This file contains hidden or 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
| const I = a => a | |
| // this is just wrapping before and after functions around chai's BDD `it` | |
| export const wrapIt = (before = I, after = I) => (label, fn) => { | |
| const ctx = before(); | |
| it(label, (ctx) => fn.call(ctx)); | |
| after(ctx); | |
| }; | |
This file contains hidden or 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
| import React, {createClass} from 'react'; | |
| class MediaLibrary = createClass({ | |
| foo() { | |
| this.setState({foo: !this.state.foo}) | |
| }, | |
| render() { | |
| return (<Bar onFoo={this.foo} />); | |
| } | |
| } |
This file contains hidden or 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
| import {into, pipe, filter, map, propEq, prop} from 'ramda'; | |
| const doStuff = pipe( | |
| filter(propEq('status', 'active')), | |
| map(prop('age')) | |
| ); | |
| // only iterates array once | |
| into([], doStuff, [{status: 'active', name: 'Pam'}, {status: 'bad', name: 'Mancy'}]); | |
| // ['Pam'] |