{"id":32977151,"url":"https://github.com/mwardle/lambdash","last_synced_at":"2026-01-11T23:03:05.251Z","repository":{"id":78214596,"uuid":"46839365","full_name":"mwardle/lambdash","owner":"mwardle","description":"Generic functional programming for JavaScript","archived":false,"fork":false,"pushed_at":"2018-03-24T23:13:48.000Z","size":305,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-06T03:44:55.361Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mwardle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-11-25T05:24:54.000Z","updated_at":"2025-07-08T01:10:22.000Z","dependencies_parsed_at":"2023-03-09T16:15:34.066Z","dependency_job_id":null,"html_url":"https://github.com/mwardle/lambdash","commit_stats":null,"previous_names":["mwardle/lambdash","mwardle/funkit"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/mwardle/lambdash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwardle%2Flambdash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwardle%2Flambdash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwardle%2Flambdash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwardle%2Flambdash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mwardle","download_url":"https://codeload.github.com/mwardle/lambdash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mwardle%2Flambdash/sbom","scorecard":{"id":669746,"data":{"date":"2025-08-11","repo":{"name":"github.com/mwardle/lambdash","commit":"9c24f063ca32f478230df86e450f22db947d65b8"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T19:33:10.013Z","repository_id":78214596,"created_at":"2025-08-21T19:33:10.013Z","updated_at":"2025-08-21T19:33:10.013Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28326166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T22:11:01.104Z","status":"ssl_error","status_checked_at":"2026-01-11T22:10:58.990Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-11-13T06:00:32.662Z","updated_at":"2026-01-11T23:03:05.245Z","avatar_url":"https://github.com/mwardle.png","language":"JavaScript","readme":"# Lambdash\n\nLambdash is a library for generic functional programming in JavaScript.\n\nLamdash enables you to create custom data types that are on equal footing with\nthe types built into the javascript language.\nIt also enables you to write your code in a point-free, functional style.\n\nThe library is built on two concepts: modules, and interfaces (aka typeclasses).\nEvery value has a module.  This is almost always the value's constructor.\nA module provides all the functions that operate on a type.\n\nAn interface defines a set of operations that must be implemented by a module for a type.\nTypically, implementing an interface allows for other operations to be performed on the value.\nThe idea is that a little effort can result in a large payoff in terms of the functionality\nthat lambdash can provide for your types.\n\nLamdash attempts to provide a mostly pure functional api.\nThis includes curried functions and operations that do not modify the values they operate on (immutability).\n\n*Contents*\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n\n\n- [Interfaces](#interfaces)\n  - [Eq](#eq)\n  - [Ord](#ord)\n  - [Bounded](#bounded)\n  - [Enum](#enum)\n  - [Functor](#functor)\n  - [Semigroup](#semigroup)\n  - [Monoid](#monoid)\n  - [Applicative](#applicative)\n  - [Monad](#monad)\n  - [Foldable](#foldable)\n  - [Sequential](#sequential)\n  - [SetOps](#setops)\n  - [Set](#set)\n  - [Associative](#associative)\n  - [Show](#show)\n- [Modules For Built-in Types](#modules-for-built-in-types)\n  - [Any](#any)\n  - [Bool](#bool)\n  - [Num](#num)\n  - [Int](#int)\n  - [Str](#str)\n  - [Arr](#arr)\n  - [Obj](#obj)\n  - [Regex](#regex)\n  - [DT](#dt)\n  - [Fun](#fun)\n  - [Unit](#unit)\n  - [The future](#the-future)\n- [Creating Types](#creating-types)\n  - [Creating a Module](#creating-a-module)\n  - [Product Types](#product-types)\n  - [Sum Types](#sum-types)\n  - [Enumerated Types](#enumerated-types)\n  - [Implementing Interfaces](#implementing-interfaces)\n- [Roadmap](#roadmap)\n  - [Plans For Next Release](#plans-for-next-release)\n  - [Future Plans](#future-plans)\n- [Additional Libraries](#additional-libraries)\n- [Contributing](#contributing)\n- [Tests](#tests)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Interfaces\n\nLambdash defines several standard interfaces (a.k.a. type classes) for custom and built in types.\nThese interfaces allow generic functions to operate on implementing types in a manner specific to the data type being operated on.\nIn general, these interfaces mirror the standard type classes in Haskell, though many functions are renamed to those more familiar to JavaScript.\n\n### Eq\n\nEq is an interface which defines equality between items of the same type.\nIn particular, it is intended to test for *structural* equality.\n\n#### Minimal Implementation\n\n1. `eq`: `a -\u003e a -\u003e Boolean`\n\n#### Derived Functions\n\n1. `neq`: `a -\u003e a -\u003e Boolean`\n\n#### Examples\n\n```javascript\nvar arr1 = [1,2,3];\nvar arr2 = [1,2,3];\nvar arr3 = [1,2,3,4];\n\n_.eq(arr1, arr2);  // true\n_.neq(arr1, arr2); // false\n\n_.eq(arr1, arr3);  // false\n_.neq(arr1, arr3); // true\n```\n\n### Ord\n\nOrd is an interface for the ordering of elements.\n\nTo facilitate ordering, Lambdash provides an algebraic data type for ordering called *Ordering*.\n\n```javascript\n// represents a \"less than result\"\n_.Ordering.LT === _.LT\n\n// represents a \"greater than result\"\n_.Ordering.GT === _.GT\n\n// represents an \"equal to result\"\n_.Ordering.EQ === _.EQ\n```\n\nTypes that implement Ord must also implement Eq.\n\n#### Minimal Implementation\n\n1. `compare`: `a -\u003e a -\u003e Ordering`\n\n#### Derived Functions\n\n1. `lt`: `a -\u003e a -\u003e Boolean`\n2. `gt`: `a -\u003e a -\u003e Boolean`\n3. `lte`: `a -\u003e a -\u003e Boolean`\n4. `gte`: `a -\u003e a -\u003e Boolean`\n5. `min`: `a -\u003e a -\u003e a`\n6. `max`: `a -\u003e a -\u003e a`\n\n#### Examples\n\n```javascript\n_.compare(1, 2);             // _.LT\n_.compare('cat', 'cab');     // _.GT\n_.compare([1,2,3], [1,2,3]); // _.EQ\n\n_.lt(1, 2);             // true\n_.gt('boat', 'coat');   // false\n\n_.min(43, 56);          // 43\n_.max([1,2,3], [1,2,4]) // [1,2,4]\n```\n\n### Bounded\n\nBounded is an interface for types that have a maximum and minimum bound\n\n#### Minimal Implementation\n\n1. `minBound`: `() -\u003e a`\n2. `maxBound`: `() -\u003e a`\n\n#### Derived Functions\n\n1. `isMin`: `a -\u003e Boolean`\n2. `isMax`: `a -\u003e Boolean`\n\nAdditionally, the generic `_.minBound` and `_.maxBound` functions accepts a value and return the minBound and maxBound for the values type, respectively.\n\n#### Examples\n\n```javascript\n_.isMin(false);    // true\n_.isMin(true);     // false\n\n_.isMax(false);    // false\n_.isMax(true);     // true\n\n_.minBound(true);  // false\n_.maxBound(true);  // true\n```\n\n### Enum\n\nThe Enum interface is for types whose values are enumerable.\nIn particular, implementing values may be converted to and from an integer in a consistent fashion.\n\nValues which implement Enum may or may not also implement Bounded.\n\n#### Minimal implementation\n\n1. `toInt`: `a -\u003e Integer`\n2. `fromInt`: `Integer -\u003e a`\n\n#### Derived Functions\n\n1. `prev`: `a -\u003e a`\n2. `next`: `a -\u003e a`\n3. `enumTo`: `a -\u003e a -\u003e Array a`\n4. `enumUntil`: `a -\u003e a -\u003e Array a`\n5. `enumFrom`: `Integer -\u003e a -\u003e Array a`\n\n#### Examples\n\n```javascript\n_.enumTo(1,5);         // [1,2,3,4,5]\n_.enumUntil(1,5);      // [1,2,3,4]\n\n_.enumTo(5,1);         // [5,4,3,2,1]\n_.enumUntil(5,1);      // [5,4,3,2]\n\n_.enumTo('A', 'E');    // ['A','B','C','D','E']\n_.enumTo(true, false); // [true,false]\n\n_.enumFrom(4, 'D');    // ['D','E','F','G']\n_.enumFrom(-3, 'Q');   // ['Q','P','O']\n\n_.enumFrom(2)('r');    // ['r','s']\n_.enumFrom(_,2)(3);    // [2,3,4]\n```\n\n\n#### Numeric\n\nThe Numeric interface is for types upon whose values algebraic operations can be performed.\n\n#### Minimal Implementation\n\n1. `toNum` -\u003e `a -\u003e Number`\n2. `fromNum` -\u003e `Number -\u003e a`\n\n#### Optional Function Implementations\n\nThe following functions may be provided for optimization.\nIf they are not provided, operations, in most cases, are performed by first converting the value to a number then back to the type.\nIt is highly recommended that these functions are implemented rather than relying on the default behavior.\n\n1. `add`: `a -\u003e a -\u003e a`\n2. `sub`: `a -\u003e a -\u003e a`\n3. `mul`: `a -\u003e a -\u003e a`\n4. `div`: `a -\u003e a -\u003e a`\n5. `mod`: `a -\u003e a -\u003e a`\n6. `abs`: `a -\u003e a`\n7. `sign`: `a -\u003e a`\n8. `negate`: `a -\u003e a`\n9. `reciprocal`: `a -\u003e a`\n10. `pow`: `a -\u003e a -\u003e a`\n\n#### Derived Functions\n\n1. `subBy`: `a -\u003e a -\u003e a`\n2. `divBy`: `a -\u003e a -\u003e a`\n3. `modBy`: `a -\u003e a -\u003e a`\n4. `powBy`: `a -\u003e a -\u003e a`\n\n\n### Functor\n\nA functor is a mappable, structure preserving type.\n\nA functor should conform to the following law:\n\n```javascript\n_.map(_.identity, a) is equal to a\n_.map(f, _.map(g, a)) is equal to _.map(_.compose(f,g), a)\n```\n\n#### Minimal Implementation\n\n1. `map`: `Functor f =\u003e (a -\u003e b) -\u003e f a -\u003e f b`\n\n#### Example\n\n```javascript\n_.map(x =\u003e x + 1, [1,2,3]);   // [2,3,4]\n```\n\n### Semigroup\n\nA semigroup is a type that whose values can be concatenated together.\nThe following law should be observed:\n\n```\n_.concat(a, _.concat(b, c)) is equal to _.concat(_.concat(a, b), c)\n```\n\n#### Minimal Implementation\n\n1. `concat`: `a -\u003e a -\u003e a`\n\n#### Derived Functions\n\n1. `concatAll`: `a... -\u003e a`\n\n#### Examples\n\n```javascript\n_.concatAll([1,2],[3,4],[5,6]);  // [1,2,3,4,5,6]\n\n_.concat([1,2],[3,4]);           // [1,2,3,4]\n_.concat([1,2])([3,4]);          // [1,2,3,4]\n_.concat(_,[1,2])([3,4]);        // [3,4,1,2]\n```\n\n### Monoid\n\nA type that implements Monoid must also implement Semigroup\n\nA Monoid is a semigroup with an empty value.\nIt must confrom to the following law:\n\n```\n_.concat(_.empty(a), a) is equal to _.concat(a, _.empty(a)) is equal to a\n```\n\n#### Minimal Implementation\n\n1. `empty`: `() -\u003e a`\n\n#### Derived Functions\n\n1. `isEmpty`: `a -\u003e Boolean`\n2. `cycleN`: `Number -\u003e m -\u003e m`\n\nAdditionally, the generic `_.empty` function accepts a value and returns the empty value for the type.\n\n#### Examples\n\n```javascript\n_.empty([1,2,3]);     // []\n_.empty(\"string\");    // \"\"\n\n_.isEmpty([1,2,3]);   // false\n_.isEmpty([]);        // true\n\n_.cycleN(3, [1,2,3]); // [1,2,3,1,2,3,1,2,3];\n_.cycleN(4, [\"ab\"]);  // \"abababab\"\n```\n\n### Applicative\n\nA type that implements applicative may have values which may be applied to other values of the type.\n\nA value that implements Applicative must first implement Functor.\n\nThe following should be true:\n\n    A.ap(A.of(f),A.of(a)) is equal to A.map(f, A.of(a))\n\n#### Minimal Implementation\n\n1. `ap`: `Applicative p =\u003e p (a -\u003e b) -\u003e p a -\u003e p b`\n2. `of`: `Applicative p =\u003e a -\u003e p a`\n\n#### Examples\n\n```javascript\n_.ap(_.Arr.of(x =\u003e x + 1), [1,2,3]);      // [2,3,4]\n_.ap([x =\u003e x + 1, x =\u003e x * 2], [1,2,3]);  // [2,3,4,2,4,6]\n```\n\n### Monad\n\nA monad is a chainable container type.\n\nA type that implements Monad must first implement Applicative\n\n#### Minimal Implementation\n\n1. `flatten`: `Monad m =\u003e m (m a) -\u003e m a`\n\n#### Optional Function Implementations\n\n1. `chain`: `Monad m =\u003e (a -\u003e m b) -\u003e m a -\u003e m b`\n\nAdditionally, functions that operate on monads may be composed or piped using the `_.composeM` and `_.pipeM` functions.\nThese functions behave in a similar manner to `_.compose` and `_.pipe` except that the functions are joined with the `_.chain` function.\n\n#### Examples\n\n```javascript\n\n    var Maybe = require('lambdash.maybe'),\n        Just = Maybe.Just,\n        None = Maybe.None;\n\n    _.flatten(Just(Just(1)));       // Just(1)\n    _.flatten(Just(None));          // None\n    _.flatten(None);                // None\n\n    _.flatten([[1,2],[3,4],[5,6]]);        // [1,2,3,4,5,6]\n\n    _.chain(n =\u003e [n, n * 2], [1,2,3]);     // [1,2,2,4,3,6]\n\n    var add1 = x =\u003e [_.add(x,1)];\n    var mul2 = x =\u003e [_.mul(x,2)];\n    var sub2 = x =\u003e [_.sub(x,2)];\n\n    var composed = _.composeM(add1, mul2, sub2);\n    composed([3,4,5]);                     // [3,5,7]\n\n    var piped = _.pipeM(add1, mul2, sub2);\n    piped([3,4,5]);                        // [6,8,10]\n\n```\n\n### Foldable\n\nThe Foldable interface is for container types that can be folded into a value.\n\n#### Minimal Implementation\n\n2. `foldl`: `Foldable f =\u003e (b -\u003e a -\u003e b) -\u003e b -\u003e f a -\u003e b`\n3. `foldr`: `Foldable f =\u003e (b -\u003e a -\u003e b) -\u003e b -\u003e f a -\u003e b`\n\n#### Derived Functions\n\n1. `foldMap`: `(Foldable f, Monoid m) =\u003e (a -\u003e m) -\u003e f a -\u003e m`\n2. `foldMap2Def`: `(Foldable f, Monoid m) =\u003e (a -\u003e m) -\u003e m -\u003e f a -\u003e m`\n3. `join`: `(Foldable f, Monoid m) =\u003e f m -\u003e m`\n4. `joinDef`: `(Foldable f, Monoid m) =\u003e m -\u003e f m -\u003e m`\n3. `joinWith`: `(Foldable f, Monoid m) =\u003e m -\u003e f m -\u003e m`\n4. `joinWithDef`: `(Foldable f, Monoid m) =\u003e m -\u003e m -\u003e f m -\u003e m`\n5. `toArray`: `Foldable f =\u003e f a -\u003e Array a`\n6. `len`: `Foldable f =\u003e f a -\u003e Integer`\n7. `isEmpty`: `Foldable f =\u003e f a -\u003e Boolean`\n8. `isNotEmpty`: `Foldable f =\u003e f a -\u003e Boolean`\n9. `contains`: `(Foldable f, Eq a) =\u003e a -\u003e f a -\u003e Boolean`\n10. `notContains`: `(Foldable f, Eq a) =\u003e a -\u003e f a -\u003e Boolean`\n11. `any`: `Foldable f =\u003e (a -\u003e Boolean) -\u003e f a -\u003e Boolean`\n12. `all`: `Foldable f =\u003e (a -\u003e Boolean) -\u003e f a -\u003e Boolean`\n13. `countWith`: `Foldable f =\u003e (a -\u003e Boolean) -\u003e f a -\u003e Number`\n13. `count`: `(Foldable f, Eq e) =\u003e e -\u003e f e -\u003e Number`\n13. `fold1`: `Foldable f =\u003e (b -\u003e a -\u003e b) -\u003e f a -\u003e b`\n14. `foldl1`: `Foldable f =\u003e (b -\u003e a -\u003e b) -\u003e f a -\u003e b`\n15. `foldr1`: `Foldable f =\u003e (b -\u003e a -\u003e b) -\u003e f a -\u003e b`\n16. `maximum`: `(Foldable f, Ord a) =\u003e f a -\u003e a`\n17. `minimum`: `(Foldable f, Ord a) =\u003e f a -\u003e a`\n18. `sum`: `(Foldable f, Numeric a) =\u003e f a -\u003e a`\n19. `product`: `(Foldable f, Numeric a) =\u003e f a -\u003e a`\n\n\n### Sequential\n\nThe Sequential interface is for containers whose values are ordered and indexable.\n\nA type that implements Sequential must first implement Foldable and Monoid.\n\n#### Minimal Implementation\n\n1. `nth`: `Sequential s =\u003e Number -\u003e s a -\u003e a`\n2. `of`: `Sequential s =\u003e a -\u003e s a`\n\n#### Optional Function Implementations\n\n1. `len`: `Sequential s =\u003e s -\u003e Number`\n2. `append`: `Sequential s =\u003e a -\u003e s a -\u003e s a`\n3. `prepend`: `Sequential s =\u003e a -\u003e s a -\u003e s a`\n4. `slice`: `Sequential s =\u003e Number -\u003e Number -\u003e s a -\u003e s a`\n5. `intersperse`: `Sequential s =\u003e a -\u003e s a -\u003e s a`\n6. `reverse`: `Sequential s =\u003e s a -\u003e s a`\n7. `filter`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e s a`\n8. `uniqueBy`: `Sequential s =\u003e (a -\u003e b) -\u003e s a -\u003e s a`\n9. `findIndex`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e Number`\n10. `findLastIndex`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e Number`\n\n#### Derived Functions\n\n1. `take`: `Sequential s =\u003e Number -\u003e s a -\u003e s a`\n2. `drop`: `Sequential s =\u003e Number -\u003e s a -\u003e s a`\n3. `takeLast`: `Sequential s =\u003e Number -\u003e s a -\u003e s a`\n4. `dropLast`: `Sequential s =\u003e Number -\u003e s a -\u003e s a`\n5. `head`: `Sequential s =\u003e s a -\u003e a`\n6. `last`: `Sequential s =\u003e s a -\u003e a`\n7. `tail`: `Sequential s =\u003e s a -\u003e s a`\n8. `init`: `Sequential s =\u003e s a -\u003e s a`\n9. `splitAt`: `Sequential s =\u003e Number -\u003e s a -\u003e Array (s a)`\n10. `takeWhile`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e s a`\n11. `dropWhile`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e s a`\n12. `takeLastWhile`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e s a`\n13. `dropLastWhile`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e s a`\n14. `unique`: `Sequential s =\u003e s a -\u003e s a`\n15. `find`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e a`\n16. `findLast`: `Sequential s =\u003e (a -\u003e Boolean) -\u003e s a -\u003e a`\n17. `indexOf`: `Sequential s =\u003e a -\u003e s a -\u003e Number`\n18. `lastIndexOf`: `Sequential s =\u003e a -\u003e s a -\u003e Number`\n\n### SetOps\n\nSetOps is an interface for performing common set operations on\n\n#### Minimal Implementation\n\n1. `union`: `SetOps s =\u003e s -\u003e s -\u003e s`\n2. `difference`: `SetOps s =\u003e s -\u003e s -\u003e s`\n3. `intersection`: `SetOps s =\u003e s -\u003e s -\u003e s`\n4. `symmetricDifference`: `SetOps s =\u003e s -\u003e s -\u003e s`\n\n\n#### Derived Functions\n\nThere are none.\n\n### Set\n\nSet is an interface for a collection of (logical) unique values.\n\nA type that implements set must also implement SetOps.\n\n#### Minimal Implementation\n\n1. `exists`: `Set s =\u003e k -\u003e s k -\u003e Boolean`\n2. `insert`: `Set s =\u003e k -\u003e s k -\u003e s k`\n3. `remove`: `Set s =\u003e k -\u003e s k -\u003e s k`\n\n#### Derived Functions\n\nThere are none.\n\n### Associative\n\nThe Associative interface is for containers that map keys to values.\n\n#### Minimal Implementation\n\n1. `assoc`: `Associative a =\u003e k -\u003e v -\u003e a k v -\u003e a k v`\n2. `dissoc`: `Associative a =\u003e k -\u003e a k v -\u003e a k v`\n3. `exists`: `Associative a =\u003e k -\u003e a k v -\u003e Boolean`\n4. `lookup`: `Associative a =\u003e k -\u003e a k v -\u003e v`\n\n#### Optional Functions\n\nThese functions may be implemented, but they are not required nor are they derived.\n\n1. `keys`: `Associative a =\u003e a k v -\u003e Array k`\n2. `values`: `Associative a =\u003e a k v -\u003e Array v`\n3. `mapAssoc`: `Associative a =\u003e (v -\u003e k -\u003e v) -\u003e a k v -\u003e a k v`\n4. `foldlAssoc`: `Associative a =\u003e (b -\u003e v -\u003e k -\u003e b) -\u003e b -\u003e a k v -\u003e b`\n5. `foldrAssoc`: `Associative a =\u003e (b -\u003e v -\u003e k -\u003e b) -\u003e b -\u003e a k v -\u003e b`\n6. `filterAssoc`: `Associative a =\u003e (v -\u003e k -\u003e Boolean) -\u003e a k v -\u003e a k v`\n\n#### Derived Functions\n\n1. `lookupAll`: `(Functor f, Associative a) =\u003e f k -\u003e a k v -\u003e f v`\n2. `lookupOr`: `Associative a =\u003e v -\u003e k -\u003e a k v -\u003e v`\n3. `update`: `Associative a =\u003e k -\u003e (v -\u003e v) -\u003e a k v -\u003e a k v`\n4. `updateOr`: `Associative a =\u003e v -\u003e k -\u003e (v -\u003e v) -\u003e a k v -\u003e a k v`\n\nAdditionally, if the type implements foldlAssoc the following is derived:\n\n1. `pairs`: `Associative a =\u003e a k v -\u003e Array Array(k,a))`\n\n### Show\n\nThe show type is for converting a datatype to a string representation.\n\n#### Minimal Implementation\n\n1. `show`: `Show s =\u003e s -\u003e String`\n\n## Modules For Built-in Types\n\nLambdash provides a module for most of the built-in types.\nIf one is not provided, it the Obj module is the default.\nAll of the functions listed for each module are attached to the root lambdash object.\n\n### Any\n\nThe any type can be any value.\nIt exists for validation when creating algebraic data types.\n\n\n#### Implements\n\nNothing.\n\n#### Functions\n\nNone.\n\n### Bool\n\nThe Bool module is for Boolean values.\n\n#### Implements\n\n1. Eq\n2. Ord\n3. Enum\n4. Show\n\n#### Functions\n\n1. `and`: `Boolean -\u003e Boolean -\u003e Boolean`\n2. `or`: `Boolean -\u003e Boolean -\u003e Boolean`\n3. `xor`: `Boolean -\u003e Boolean -\u003e Boolean`\n4. `not`: `Boolean -\u003e Boolean`\n5. `both`: `(*... -\u003e Boolean) -\u003e (*... -\u003e Boolean) -\u003e (*... -\u003e Boolean)`\n6. `either`: `(*... -\u003e Boolean) -\u003e (*... -\u003e Boolean) -\u003e (*... -\u003e Boolean)`\n7. `neither`: `(*... -\u003e Boolean) -\u003e (*... -\u003e Boolean) -\u003e (*... -\u003e Boolean)`\n8. `eitherExclusive`: `(*... -\u003e Boolean) -\u003e (*... -\u003e Boolean) -\u003e (*... -\u003e Boolean)`\n9. `complement`: `(*... -\u003e Boolean) -\u003e (*... -\u003e Boolean)`\n10. `condition`: `[(*... -\u003e Boolean), (*... -\u003e a)]... -\u003e (*... -\u003e a)`\n11. `T`: `() -\u003e Boolean`\n12. `F`: `() -\u003e Boolean`\n\n### Num\n\nThe Num module is for Number values.\n\n#### Implements\n\n1. Eq\n2. Ord\n3. Enum\n4. Numeric\n5. Show\n\n#### Functions\n\nNo additional functions.\n\n### Int\n\nThe Int module is only meant to act as a constraint for numbers that should always be integral.\nCurrently a number will always use the Num module for its functionality.\n\n#### Implements\n\nNothing\n\n#### Functions\n\nNo additional functions.\n\n### Str\n\nThe Str module is for string values.\n\n#### Implements\n\n1. Eq\n2. Ord\n3. Enum (uses the first character of the string)\n4. Functor\n5. Semigroup\n6. Monoid\n7. Foldable\n8. Sequential\n9. Show\n\n#### Functions\n\n1. `split`: `String|RegExp -\u003e String -\u003e Array String`\n2. `match`: `RegExp -\u003e String -\u003e Array String`\n3. `replace`: `String|RegExp -\u003e String -\u003e String -\u003e String`\n4. `toLower`: `String -\u003e String`\n5. `toUpper`: `String -\u003e String`\n6. `trim`: `String -\u003e String`\n7. `lines`: `String -\u003e Array String`\n8. `words`: `String -\u003e Array String`\n9. `unlines`: `Foldable f =\u003e f String -\u003e String`\n10. `unwords`: `Foldable f =\u003e f String -\u003e String`\n\n### Arr\n\nArr is the lambdash module for Arrays.\n\n#### Implements\n\n1. Eq (if its elements implement Eq)\n2. Ord (if its elements implement Ord)\n3. Functor\n4. Foldable\n5. Semigroup\n6. Monoid\n7. Applicative\n8. Monad\n9. Sequential\n10. SetOps\n11. Set\n12. Show (if its elements implement Show)\n\n#### Functions\n\n1. `applyTo`: `(* -\u003e *) -\u003e Array *  -\u003e *`\n\n### Obj\n\nObject is the lambdash module for objects.\n\n#### Implements\n\n1. Eq (if its values implement Eq)\n2. Ord (if its values implement Ord)\n3. Functor\n4. Semigroup (concat is a right biased union)\n5. Monoid\n6. SetOps\n7. Foldable\n8. Associative (with optional functions)\n9. Show (if its values implement Show, keys are sorted)\n\n#### Functions\n\n1. `copy`: `{String: a} -\u003e {String: a}`\n2. `copyOwn`: `{String: a} -\u003e {String: a}`\n3. `propExists`: `String -\u003e {String: a} -\u003e Boolean`\n4. `ownPropExists`: `String -\u003e {String: a} -\u003e Boolean`\n5. `prop`: `String -\u003e {String: a} -\u003e a|undefined`\n6. `propOr`: `a -\u003e String -\u003e {String: a} -\u003e a`\n7. `props`: `Foldable f =\u003e f String -\u003e {String: a} -\u003e f a`\n8. `propNames`: `{String: a} -\u003e [String]`\n9. `ownPropNames`: `{String: a} -\u003e [String]`\n10. `ownValues`: `{String: a} -\u003e [a]`\n11. `ownPairs`: `{String: a} -\u003e [[String, a]]`\n12. `filter`: `(a -\u003e Boolean) -\u003e {String: a} -\u003e {String: a}`\n\n### Regex\n\nRegex is the lambdash module for regular expression objects.\n\n#### Implements\n\n1. Show\n\n#### Functions\n\n1. `test`: `String -\u003e RegExp -\u003e Boolean`\n2. `exec`: `String -\u003e RegExp -\u003e [String]`\n\n#### Notes\n\nA 3rd-party package could be created to extend this functionality.\n\n### DT\n\nDT is the lambdash module for DateTime objects.\n\n#### Implements\n\n1. Eq\n2. Ord\n3. Numeric\n4. Show\n\n#### Functions\n\nNone.\n\n#### Notes\n\nA 3rd-party package should be created to extend this functionality.\n\n### Fun\n\nFun is the lambdash module for Functions.\n\n#### Implements\n\nNothing.\n\n#### Functions\n\n1. `compose`: `(*... -\u003e *)... -\u003e (*... -\u003e *)`\n2. `pipe`: `(*... -\u003e *)... -\u003e (*... -\u003e *)`\n3. `always`: `a -\u003e (() -\u003e a)`\n4. `alwaysThrow`: `(*... -\u003e Error) -\u003e *... -\u003e (() -\u003e ())`\n5. `thunk`: `(*... -\u003e *) -\u003e *... -\u003e (() -\u003e *)`\n6. `identity`: `a -\u003e a`\n7. `curry`: `(*...-\u003e *) -\u003e (*... -\u003e *)`\n8. `curryN`: `Number -\u003e (*... -\u003e *) -\u003e (*... -\u003e *)`\n9. `arity`: `Number -\u003e (*... -\u003e *) -\u003e (*... -\u003e *)`\n10. `make`: `String -\u003e (*... -\u003e *) -\u003e (*... -\u003e *)`\n11. `thisify`: `(*... -\u003e *) -\u003e (*... -\u003e *)`\n12. `liftN`: `Applicative a =\u003e -\u003e Number -\u003e (*... -\u003e c) -\u003e ((a *)... -\u003e a c)`\n13. `lift`: `(*... -\u003e c) -\u003e ((a *)... -\u003e a c)`\n14. `apply`: `Foldable f =\u003e f * -\u003e (*... -\u003e a) -\u003e a`\n15. `noop`: `() -\u003e ()`\n16. `flip`: ``\n\n### Unit\n\nUnit is the module for undefined and null values.\n\n#### Implements\n\n1. Eq (always true)\n2. Ord (always EQ)\n3. Semigroup (always null)\n4. Monoid\n5. Functor (always null)\n6. Show\n\n#### Functions\n\nNone\n\n### The future\n\nThe library does not yet support ECMAScript 2015 types.\nThere are plans for adding support for them.\n\n## Creating Types\n\nLambdash provides a way to declare new algebraic data types.\nIt also provides a mechanism that will make lambdash start treating your types as modules,\nwhich allows all of lambdash's generic functions to operate on your types instances.\n\n### Creating a Module\n\nLambdash does not all care about an objects prototype.\nInstead, it cares about modules.\nEvery object has module.\nFor custom types, by default, this module is lamdash's Obj module.\nHowever, the whole point of the library is to allow the user the ability to\ncreate their own types which will have an equal status with all the other types.\n\nLamdash provides a function, `_.Type.moduleFor`, which will return the module for a value.\nThe following is the process through which the module is identified:\n\n1. If the value is null or undefined, return the Unit module\n2. If the values constructor is a module and a submodule, return the constructor's parent module.\n3. If the values constructor is a module, return the constructor\n4. Return the appropriate module for built-in types.\n\nA type can be declared as a module using the `_.Type.module` function.\n\n```javascript\n\n// this example uses a constructor function since it is an easy\n// way to set a constructor for a value\nfunction Example(x) {\n    this.whatever = x\n}\n\nvar ex = new Example(1);\n\n_.Type.moduleFor(ex);   // _.Type.Obj\n\n// make Example a module\n_.Type.module(Example);\n_.Type.ModuleFor(ex);  // Example\n\n```\n\nSubmodules can be defined with the `_.Type.subModule` function.  \nThe first parameter is the parent module, the second is the submodule.\nThe submodule should also be declared as a module.\nThis functionality exists for sum types.\n\nModules will probably also want to add a `member` function.\nThe `member` function should accept a single value and return true if the value\nis a member of the type, false if not.\n\n### Product Types\n\nLamdash has a way to create product types.\nA product type is a type that has a fixed number of labelled or non-labelled elements.\n\nProduct types are automatically created as modules.\n\nA Product type should specify a name as its first argument and a definition as its second argument.\nThe definition may be an object or an array.\nIf the definition is an object, the keys will be the fields of the product type and the values\nwill be constraints.\nIf the definition is an array, its values should be constraints.\n\nConstraints may be a type with a member function, a function that accepts a value and\nreturns true or false, or null.\nIf the constraint is null, the value may be of any type, but must be defined.\n\nEvery product type will automatically implement Eq (assuming its field implement Eq).\nThey will also have an unapply function.\n\n```javascript\n\nvar Point = _.Type.product('Point', {x: _.Num, y: _.Num});\n\nvar p = Point(1,2);\np instanceof Point;  // true\n_.Type.moduleFor(p); // Point\nPoint.name;          // \"Point\"\nPoint.member(point); // true\n\np.x;  // 1\np.y;  // 2\np[0]; // 1\np[1]; // 2\n\nvar p2 = Point('a', 'b'); // TypeError\n\n// with an array\nvar Point = _.Type.product('Point', [_.Num, _.Num]);\n\np._0;  // 1\np._1;  // 2\np[0]; // 1\np[1]; // 2\n\n_.eq(Point(1,2), Point(1,2)); // true\n_.eq(Point(1,2), Point(1,3)); // false\n\n_.unapply(function(x,y){console.log('x:'+x+',y:',y)}, p);  // 'x:1,y:2'\n\n```\n\nEvery product type will automatically implement Eq (assuming its field implement Eq).\nThey will also have an unapply function.\n\n### Sum Types\n\nSum types are a type that can be an instance of any one of its sub types.\n\nTo create a sum type pass a name as a string or a *named* function as the first\nparameter, and a definition object to the second parameter of the `_.Type.sum` function.\nThe definition must be an object with the keys as the names of the subtypes, and\nthe values as product type definitions.\nThe keys must be valid identifier names.\n\nIf a definition of a subtype is empty, a single instance will be created and attached\nto the sum type rather than the constructor.\n\nEvery sum type will implement Eq and will also have a case function which can be\nuse for simple matching of the type of the value.\n\n```javascript\n\nvar Maybe = _.Type.sum('Maybe', {'None': [], 'Some': {value: _.Any}});\n\nvar maybe = Maybe.None;\nmaybe instancof Maybe;  // true\nMaybe.member(maybe);    // true\n\n_.Type.moduleFor(maybe); // Maybe\n\nmaybe = Maybe.Some(1);\nmaybe instanceof Maybe;      // true\nmaybe instanceof Maybe.Some; // true\nMaybe.member(maybe);         // true\n\nvar value = _.case({\n    None: 0,\n    Some: function(v) {\n        return v + 1;\n    }\n}, maybe);\n// value is 2\n\n// case with a default\nvalue = _.case({\n    None: 1,\n    _: 0\n}, maybe);\n// value is 0\n\n// creating maybe with a function\nvar Maybe = function(value) {return value == null ? Maybe.None : Maybe.Some(value) }\nMaybe = _.Type.sum(Maybe, {'None': [], 'Some': {value: _.Any}});\n\nMaybe(1);    // Some(1)\nMaybe(null); // None\n\n```\n\n### Enumerated Types\n\nEnumerated types are a special case of Sum types in which there are no values\nassociated with any of the sub types.\n\nEnumerated types will automatically implement Ord, Bounded, and Enum.\n\n```javascript\n\nvar Days = _.Type.enumerated('Days', ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']);\n\n_.enumFrom(Days.Tue, Days.Fri); // [Tue, Wed, Thu, Fri]\n_.lt(Days.Tue, Days.Thu);       // true\n\nDays.maxBound();   // 'Sun'\nDays.minBound();   // 'Mon'\n\n```\n\n### Implementing Interfaces\n\nCustom types may implement interfaces by creating the correct functions.\n\nFor example, consider implementing functor for the maybe type.  \nThe functor interface requires that the type implement `Map`.\n\n```javascript\n\nvar Maybe = _.Type.sum('Maybe', {None: [], Some: {value: _.Any}});\n\nvar m = Maybe.Some(1);\n\n_.Functor.member(m);  // false\n\nMaybe.map = _.curry(function(fn, maybe){\n    if (maybe === Maybe.None) {\n        return maybe;\n    }\n    return Maybe.Some(fn(maybe.value));\n});\n\n_.Functor.member(m);         // true\n\n_.map(_.add(2), m);          // Some(3)\n_.map(_.add(2), Maybe.None); // None\n\n```\n\n## Roadmap\n\nI feel that the 0.6.0 release is very significant release.\nIt is the first release that I actually feel comfortable using in a real application.\n\nThat being said, there is more work to do.\n\nAfter the 0.6.0 release, I intend on improving the workflow.  \nThe master branch will always contain the most recent stable release and development\nwill take place in other branches.\n\n### Plans For Next Release\n\nThe following is either planned or under review for the 0.7.0 release.\n\n1. Implement modules for the new ECMAScript 2015 types\n2. Figure out what to do with the Int module and what exactly its role in the library is\n3. Adding Unicode processing functions to the Str module\n4. Possibly adding a way to create a Union type (like a sum type from existing types)\n5. Improve and further standardize docblocks and generate api docs\n\n### Eventual Plans\n\n1. Create a script that will amalgamate the files into one and minimize for the browser.\n2. Create benchmarks.\n3. Create a website for the library.\n4. Create an external module that will improve or replace the DT module.\n\n\n## Additional Libraries\n\nAdditional libraries for lambdash are either available or under development.\n\n1. Task (For asynchronous computations)\n2. List\n3. Maybe\n4. Either\n\nIf you have developed an additional library for lamdash, please let me know\nso that I can list it here.\n\n## Contributing\n\nI am happy to take pull requests If anybody wants to contribute.\n\n## Tests\n\nTo run tests:\n\n```\nnpm install --dev\nnpm test\n```\n\nTo run the coverage report:\n\n```\nnpm run coverage\n```\n","funding_links":[],"categories":["Libraries"],"sub_categories":["[Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwardle%2Flambdash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmwardle%2Flambdash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmwardle%2Flambdash/lists"}