How to use the sanctuary-def.AnyFunction 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 xodio / hm-def / src / index.js View on Github external
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,
  ])
  (({$, checkTypes, env, typeClasses}) => {
    const $def = $.create ({checkTypes, env});
    const resovleSig = Sig.resolve ($) (typeClasses) (env);

    return $def
      ('def')
      ({})
      ([$.String, $.AnyFunction])
      (signature => func => {
        const params = resovleSig (signature);
        return $def
          (params.name)
          (params.constraints)
          (params.types)