Ramda | Sanctuary |
---|---|
add(a, b) |
add(b, a) |
addIndex(f) |
`` |
adjust(f, i, xs) |
`` |
all(f, xs) |
`` |
allPass(fs, x) |
allPass(fs, x) |
always(x) |
K(x) |
and(a, b) |
and(a, b) |
any(f, x) |
`` |
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 from 'react' | |
import hoistNonReactStatics from 'hoist-non-react-statics' | |
export default function withFlexibleRender (OriginalComponent) { | |
class ComponentWithFlexibleRender extends OriginalComponent { | |
render () { | |
const { children, render } = this.props | |
const args = { |
-
create-react-native-app purescript-app; cd purescript-app
-
pulp init --force
-
pulp build
-
src/Main.js
var React = require("react");
var RN = require("react-native");
exports.text = function(props){
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
// a simpler version of Ramda's `cond` where you can only match a value against | |
// an object's static key, like how JavaScript's `switch` statement works with `case` | |
// if you need to dynamically match against expression evaluations, use `cond` instead | |
const matchObj = casesObj => fallback => val => casesObj[val] || fallback | |
// or with a syntax more like Ramda's `cond`, taking in an array of pairs instead | |
const matchPairs = compose(matchObj, fromPairs) |
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
// try in ramda's repl: https://goo.gl/VsRkoY | |
const expMatch = cases => fallback => matchVal => { | |
const sanitize = maybeString => | |
typeof maybeString === 'string' || maybeString instanceof String | |
? `'${maybeString}'` | |
: maybeString | |
// dynamically build a switch statement to be eval'd | |
const switchStart = `switch (true) {\n` |
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
use std::rc::Rc; | |
trait HKT<U> { | |
type C; // Current type | |
type T; // Type with C swapped with U | |
} | |
macro_rules! derive_hkt { | |
($t:ident) => { | |
impl<T, U> HKT<U> for $t<T> { |
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
#!/usr/bin/env stack | |
-- stack --resolver lts-10.8 --install-ghc exec ghci | |
{-# LANGUAGE ConstraintKinds #-} | |
{-# LANGUAGE ExistentialQuantification #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE LambdaCase #-} | |
-- A key type for pretend use in looking up a doggo in a database. | |
newtype Key a = Key { unKey :: String } |
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 classNamesBy = mapper => R.compose( | |
R.trim, | |
R.join(' '), | |
R.chain(mapper), | |
R.toPairs, | |
) | |
const classNames = R.curry((base, obj) => { | |
const standard = ([k, v]) => [v ? k : ''] | |
const reversed = R.compose(standard, R.reverse) |
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
"use strict"; | |
var React = require("react"); | |
var ReactDOM = require("react-dom"); | |
exports.makeRef = function(toMaybe) { | |
var Ref = function(props) { | |
this.DOMNode = null; | |
return this; | |
}; |
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 { | |
end, | |
int, | |
lit, | |
Match, | |
parse, | |
Route as RouteBase, | |
zero | |
} from "fp-ts-routing"; | |
import { pipe } from "fp-ts/lib/function"; |