Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
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.
FAQs
Monad and Monad Transformer Collection
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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.