New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

akh.error

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akh.error

Akh error monad and monad transformer

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
520
decreased by-8.93%
Maintainers
1
Weekly downloads
 
Created
Source

Error Monad and Monad Transformer for Akh Javascript Monad Library

The ErrorT transformer, ErrorT, adds error control to a monad. The base type, Error, provides error logic on its own.

# To use as standalone package
$ npm install --save akh.error

# To use as part of akh library
$ npm install --save akh

Usage

The ErrorT and Error implement the Fantasy Land monad, functor, and applicative functor interfaces.

Fantasy Land logo
// Error monad
require('akh.error').Error
require('akh').Error

// Error monad transformer
require('akh.error').ErrorT
require('akh').ErrorT
Error.run(m, ok, err), m.run(ok, err)

Perform a error computation m and invoke ok if it succeeds and err if it fails.

const c =
    Error.of(3)
        .map(x => -x);

Error.run(c, console.error, console.log); // logs: -3
ErrorT.run(t, ok, err), t.run(ok, err)

Same as Error.run but for a monad transformer. Returns an Error value inside of the inner monad.

Error.attempt(m, def), m.attempt(def)

Perform an error computation m and return the result if it succeeds and def if it fails.

Error.try(m, e), m.try(e)

Perform an error computation m and return the result if it succeeds and invoke e if it fails

Error Interface

Error.fail(x)
ErrorT(m).fail(x)

Construct a error value value.

Error.handle(f)
ErrorT(m).handle(f)

Handle an error.

Contributing

Contributions are welcome.

To get started:

$ cd akh-error
$ npm install # install dev packages
$ npm test # run tests

Keywords

FAQs

Package last updated on 03 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc