new Product()
The Product monoid. Product can be used to multiply multiple numbers into a final number via concatenation
- Version:
- 3.0.0
- Source:
Example
const {Product} = require('futils').monoid;
Product(1); // -> Product(1)
Product(1).value; // -> 1
Extends
- module:generics/Show
- module:generics/Eq
- module:generics/Ord
Methods
(static) empty() → {Product}
Monoid implementation for Product. Returns a Product of 1
- Source:
Returns:
- Type:
-
Product
The empty Product
Example
const {Product} = require('futils').monoid;
Product.empty(); // -> Product(1)
(static) of(a) → {Product}
Lifts a value into a Product. Returns a Product of 1 if the value isn't a number
- Source:
Parameters:
Name | Type | Description |
---|---|---|
a |
any
|
The value to lift |
Returns:
- Type:
-
Product
A new Product
Example
const {Product} = require('futils').monoid;
Product.of(2); // -> Product(2)
Product.of(null); // -> Product(1)
Product.of({}); // -> Product(1)
concat(a) → {Product}
Concatenates a Product with another using multiplication
- Source:
Parameters:
Name | Type | Description |
---|---|---|
a |
Product
|
The Product instance to concatenate with |
Returns:
- Type:
-
Product
A new Product
Example
const {Product} = require('futils').monoid;
const product = Product(2);
product.concat(Product(2)); // -> Product(4)