
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
1) Large flightless bird found in Fantasy Land
2) Javascript monad transformer library
$ npm install --save akh
Akh is a collection of monad and monad transformers that implement Fantasy Land's interfaces. It is inspired by Haskell's MTL.
Akh can either be used as a single library, or you can pick up individual types from split out libraries. See each library for more documentation on that type.
All functions from akh.core are top level exports.
const List = require('akh').List
const StateT = require('akh').StateT
// Define a new monad using the state transformer on the list monad.
const M = StateT(List)
// Define a way to pass values through `M`
const run = (c, state) => List.runList(StateT.runStateT(c, state))
// Create a simple stateful computation with an initial value
const start = M.of('porky')
// Run the stateful computation to get a list of
// value, state pairs
run(start, 'wackyland') === [
{ value: 'porky', state: 'wackyland' }
]
// Let's update the current state using a function
const modifiedState = start.modify(state => state.toUpperCase())
run(modifiedState, 'wackyland') === [
{ value: 'WACKYLAND', state: 'WACKYLAND' }
]
// Note that modify also updated the held value here. We could avoid that
// by instead writing
const modifiedState2 = start
.chain(currentValue =>
M.modify(state => state.toUpperCase())
.map(_ => currentValue))
run(modifiedState2, 'wackyland') === [
{ value: 'porky', state: 'WACKYLAND' }
]
// Now let's start using the list monad and branch the state.
const branched = modifiedState2
.concat(
M.put('nuts').map(_ => 100) // `put` sets the current state
)
.concat(
M.put('squirrel').map(_ => 1)
)
.concat(
M.get // gets the state
)
run(branched, 'wackyland') === [
{ value: 'porky', state: 'WACKYLAND' },
{ value: 100, state: 'nuts' },
{ value: 1, state: 'squirrel' },
{ value: 'wackyland', state: 'wackyland' }
]
// We can then operate on all states at the same time.
const doubled = branched.map(x => x + x)
run(doubled, 'wackyland') === [
{ value: 'porkyporky', state: 'WACKYLAND' },
{ value: 200, state: 'nuts' },
{ value: 2, state: 'squirrel' },
{ value: 'wackylandwackyland', state: 'wackyland' }
]
Improvement and additions to Akh are welcome. Please report any issues or send a pull request.
The Dodo Bird is a Looney Toons character created and owned by Warner Bros.
3.1.2 - July 23, 2017
FAQs
Monad and Monad Transformer Collection
The npm package akh receives a total of 520 weekly downloads. As such, akh popularity was classified as not popular.
We found that akh demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.