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

akh

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akh

Monad and Monad Transformer Collection

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
321
decreased by-29.3%
Maintainers
1
Weekly downloads
 
Created
Source

Akh

Javascript Monad and Monad Transformer Collection

Overview

Fantasy Land logo

Collection of simple monad and monad transformers that implement Fantasy Land's interfaces.

  • Documentation - Documentation of general interfaces and specific types.

Quick Example

Example is in Khepri but regular js works fine too.

with
    import 'akh::list' List,
    import 'akh::trans::state' StateT
in {

// Define a new monad using the state transformer on the list monad.
var M = StateT (List);

var run = StateT.runStateT \>> List.runList;

// Create a stateful computation
var c =
    M.of(1) // simple value
    
        // modify State
        .chain(\x ->
            M.modify \ s -> s + x + 'xyz')
        
        // Branch states
        .concat(
             M.put('new_state').map(\ -> 3),
             M.of 10,
             M.get // get the current state)
         
         // And operate on them
         .map(_ +, 'aa');

// Run the computation to get list of state value pairs
run(c, 'initial_state');
[
    {'x': '1aa', 's': 'state1xyz'},
    {'x': '3aa', 's': 'new_state'},
    {'x': '10aa', 's': 'state1xyz'}
    {'x': 'state1xyzaa', 's': 'state1xyz'}
]
}

Install

Node

Node files live in dist_node

$ npm install akh

With AMD

Node files live in dist

requirejs.config({
    paths: {
        'akh': './dist'
    }
});

require(['akh/list'], function(List) {
    ...
});

Included Types

Monad Transformers
  • IdentityT - akh::trans::identity - Transforms a monad to itself. (Monad, Functor, Applicative Functor)
  • StateT - akh::trans::state - State transformer. (Monad, Monoid, Functor, Applicative Functor)
  • ListT - akh::trans::list - List transformer. (Monad, Monoid, Functor, Applicative Functor)
  • ContT - akh::trans::cont - Continuation transformer. (Monad, Functor, Applicative Functor)
  • DContT - akh::trans::dcont - Delimited continuation transformer. (Monad, Functor, Applicative Functor)
  • EitherT - akh::trans::either - Either transformer. (Monad, Monoid, Functor, Applicative Functor)
  • ErrorT - akh::trans::error - Error transformer. (Monad, Monoid, Functor, Applicative Functor)
  • UniqueT - akh::unique Add unique int to monad (Monad, Monoid, Functor, Applicative Functor)
Monads
  • Identity - akh::identity - Identity computation. (Monad, Functor, Applicative Functor)
  • State - akh::state - Stateful computation. (Monad, Functor, Applicative Functor)
  • List - akh::list - List computation. (Monad, Monoid, Functor, Applicative Functor)
  • Cont - akh::cont - Continuation computation. (Monad, Functor, Applicative Functor)
  • DCont - akh::dcont - Delimited continuation computation. (Monad, Functor, Applicative Functor)
  • EitherT - akh::either - Either computation. (Monad, Functor, Applicative Functor)
  • ErrorT - akh::error - Error computation. (Monad, Functor, Applicative Functor)
  • Trampoline - akh::trampoline Trampolined computation (Monad, Functor, Applicative Functor)
  • Unique - akh::unique Get Unique int (Monad, Monoid, Functor, Applicative Functor)

Contribute

Improvement and additions to Akh are welcome. Please report any issues or send a pull request.

Code

Akh is written in Khepri. Khepri is an ECMAScript derived language focused on functional programming that compiles to Javascript. Khepri sources are in lib directory with node output in dist_node and AMD output in dist.

# install khepri
$ npm install -g khepri

# Compile all Khepri files
$ npm run build

# Run tests
$ npm test

# While developing, auto compile changed files
$ khepri -w lib -o dist_node --package_manager=node

Keywords

FAQs

Package last updated on 03 Apr 2014

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