Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
aljebra
Advanced tools
Readme
Aljebra provides toy implementations of the algebraic structures defined in the Fantasy Land specification, mostly borrowed from Haskell libraries.
The following objects each implement a constructor allowing you to lift values into these base objects. Many of the other instances in this library are built on top of these base objects. As such, they implement a similar constructor pattern.
Constructor | Description |
---|---|
new Id(a) | A value (Identity) |
new Optional() or new Optional(a) | An optional value |
new (new Default(a)) or new (new Default(a))() | An optional with a default value |
new Either('left', a) or new Either('right', b) | One of two types of values |
Note that new Default(a)
actually returns a constructor for an Optional
that defaults to a
. In the following sections, such constructors-for-constructors will be listed under the heading “Constructors” and all other simple constructors will be listed under “Instances”.
Constructor | Description |
---|---|
new Semigroup(concat) | Given associative binary function concat , return a Semigroup constructor. |
new Dual(s) | Given Semigroup s , flip s.concat and return a constructor for the resulting Semigroup. |
Constructor | concat |
---|---|
new Either('left', a) or new Either('right', b) | Takes the first value labelled 'right' . |
new First(a) | Takes the first a . |
new Last(a) | Takes the last a . |
new Max(a) | > |
new Min(a) | < |
This module re-exports all Monoid instances.
Constructor | Description |
---|---|
new Monoid(zero, concat) | Given value zero and binary function concat , return a Monoid constructor. |
new Dual(m) | Given Monoid m , flip m.concat and return a constructor for the resulting Monoid. |
new OptionalSemigroup(s) | Lift Semigroup s into Optional and return a constructor for the resulting Monoid. |
Constructor | zero | concat | Notes |
---|---|---|---|
new All(a) | true | && | |
new Any(a) | false | ││ | |
new Array(a) | [] | concat | |
new Endo(a) | identity function | function composition | a must be a function from values of type b to b . |
new Product(a) | 1 | * | |
new Sum(a) | 0 | + |
Instance | map(f) |
---|---|
new Id(a) | Apply f to the value. |
new Optional(a) or new Optional() | If the value exists, apply f to it. |
new Either('left', a) or new Either('right', b) | If the value is labelled 'right' , apply f to it. |
This module re-exports all Applicative instances.
This module re-exports all Monad instances.
Constructor | of | chain |
---|---|---|
new Id(a) | new Id(a) | |
new Optional(a) | new Optional(a) | A missing value short-circuits the chain. |
new Either('left', a) or new Either('right', b) | new Either('right', a) | A 'left' vale short-circuits the chain. |
freeze
s its resulting object.'use strict'
, so attempting to mutate any of the structures throws a type error../lib/common.js
. These throw errors, for example, when arguments are of the wrong type or wrong number are provided.Note: the test suite itself could be better tested!
The test suite attempts to verify that the instances of algebraic structures defined in this library satisfy the laws defined in the Fantasy Land specification. Additionally, it includes a number of noninstance "sanity checks".
Before running, make sure you have installed the package with npm install
, as the test suite relies on Mocha.
$ make about-testing
Testing
make test # Run all instance tests
make test-instances # Run all instance tests
make test-noninstances # Run all noninstance tests
make test-all # Run all tests
make test-all-verbose # Run all tests in verbose mode
make testing # Run all tests continuosly
Id:
✓ Identity (Functor)
✓ Composition (Functor)
✓ Identity (Applicative)
✓ Composition (Applicative)
✓ Homomorphism (Applicative)
✓ Interchange (Applicative)
✓ Associativity (Chain)
✓ Left Identity (Monad)
✓ Right Identity (Monad)
Difference:
✓ is not a Semigroup
Rock, Paper, Scissors:
✓ is not a Semigroup
FAQs
Toy implementations of the algebraic structures defined in the Fantasy Land specification, mostly borrowed from Haskell libraries.
The npm package aljebra receives a total of 1 weekly downloads. As such, aljebra popularity was classified as not popular.
We found that aljebra 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.