How to use the sanctuary-def.create function in sanctuary-def

To help you get started, we’ve selected a few sanctuary-def examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fabioluz / fun-js / src / fun.js View on Github external
import Sanctuary from 'sanctuary';
import $ from 'sanctuary-def';
import Z from 'sanctuary-type-classes';
import Future from 'fluture';
import FutureTypes from 'fluture-sanctuary-types';

const S = Sanctuary.create ({
  checkTypes: process.env.NODE_ENV !== 'production',
  env: Sanctuary.env.concat (FutureTypes.env)
});

const def = $.create ({
  checkTypes: process.env.NODE_ENV !== 'production',
  env: $.env.concat (FutureTypes.env)
});

$.a = $.TypeVariable ('a');
$.b = $.TypeVariable ('b');
$.Either = S.EitherType;
$.Maybe = S.MaybeType;
$.Future = FutureTypes.FutureType;

// Extensions
S.chainRej = S.curry2 ((fn, future) => future.chainRej (fn));
S.replace = S.curry3((key, replacement, str) => str.replace (key, replacement));
S.lift4 = S.curry4 ((fn, a1, a2, a3, a4) => Z.ap (Z.ap (Z.ap (Z.map (fn, a1), a2), a3), a4));
S.eitherToFuture = S.either (Future.reject) (Future.of);
S.invoke = fnName => arg => obj => obj[fnName] (arg);
github xodio / hm-def / src / index.js View on Github external
import $priv from 'sanctuary-def';
import * as Sig from './signature';

const def = $priv.create ({checkTypes: true, env: $priv.env});

const Parameters = $priv.RecordType ({
  $: $priv.Object,
  checkTypes: $priv.Boolean,
  env: $priv.Array ($priv.Type),
  typeClasses: $priv.Array ($priv.TypeClass),
});

export const create = def
  ('create')
  ({})
  ([
    Parameters,
    $priv.String,
    $priv.AnyFunction,
    $priv.AnyFunction,
github futurize / future-io / lib / types.js View on Github external
const b = $.TypeVariable('b')
const $IO = $.UnaryType(
  'future-io/IO',
  (x) => x && x['@@type'] === 'future-io/IO',
  () => []
)
const $Task = $.UnaryType(
  'Task',
  (x) => x && typeof x.fork === 'function',
  () => []
)
const env = $.env.concat([
  $IO,
  $Task
])
const def = $.create({ checkTypes: true, env })

module.exports = Object.assign({ def, a, b, $IO, $Task }, $)