Giter Site home page Giter Site logo

funfix / funland.js Goto Github PK

View Code? Open in Web Editor NEW
46.0 46.0 4.0 803 KB

Type classes for interoperability of common algebraic structures in JavaScript, TypeScript and Flow

Home Page: http://funland.funfix.org/

License: MIT License

JavaScript 23.85% TypeScript 75.65% Shell 0.50%
fantasy-land flowtype fp functional-programming javascript type-classes typescript

funland.js's Introduction

Funfix

Warning

This repository has been unmaintained and is now ARCHIVED. At the time of writing, there are better options out there, such as Effect, although this code may still provide educational value.

Funfix is a library of type classes and data types for Functional Programming in JavaScript, TypeScript and Flow.

Inspired by Scala, Cats and Monix.

Usage

The code is organized in sub-projects, for à la carte dependencies, but all types, classes and functions are exported by funfix, so to import everything:

npm install --save funfix

Or you can depend on individual sub-projects, see below.

Modules: UMD and ES 2015

The library has been compiled using UMD (Universal Module Definition), so it should work with CommonJS and AMD, for standalone usage in browsers or Node.js.

But it also provides a module definition in package.json, thus providing compatibility with ECMAScript 2015 modules, for usage when used with a modern JS engine, or when bundling with a tool chain that understands ES2015 modules, like Rollup or Webpack.

Sub-projects

Funfix has been split in multiple sub-projects for à la carte dependency management. As mentioned above, you can depend on everything by depending on the funfix project.

These sub-projects are:

funfix-core

npm

Exposes primitive interfaces and data types that need to be universally available, belonging into a standard library.

See JSDoc documentation.

Quick Overview & Usage
npm install --save funfix-core

Exposes types for expressing disjunctions:

Either data type for expressing results with two possible outcome types (a disjoint union)
Option data type for expressing optional values
Try data type for representing the result of computations that may result in either success or failure

Standard interfaces and tools for dealing with universal equality and hash code generation:

IEquals an interface for defining universal equality and hash code
is and equals for using IEquals in tests, or otherwise falls back to JavaScript's equality (== or valueOf())
hashCode for calculating hash codes (for usage in sets and maps data structures) using IEquals, or otherwise falls back to calculating a hash from .valueOf() or from .toString()
isValueObject for testing if a given object implements IEquals

Standard, reusable error types, that help with some common scenarios, working with error types being preferable to working with strings:

DummyError for tagging errors used for testing purposes
IllegalArgumentError for signaling that a given argument is violating the contract of the called function or constructor
IllegalInheritanceError for signaling that inheriting from a certain class is illegal
IllegalStateError for signaling that an illegal code branch was executed and thus something is wrong with the code and needs investigation (e.g. a bug)
NoSuchElementError thrown when the user expects an element to be returned from a function call, but no such element exists
NotImplementedError thrown in case an implementation is missing
TimeoutError thrown in case the execution of a procedure takes longer than expected
CompositeError for gathering multiple errors in a single reference that can expose them as a list

Misc utilities:

applyMixins for working with mixins (i.e. classes used as interfaces, with methods that have default implementations), see Mixins for an explanation
id is the "identity" function

funfix-exec

npm

Contains low level / side-effectful utilities and data types for building higher level concurrency tools.

See JSDoc documentation.

Quick Overview & Usage
npm install --save funfix-exec

Scheduling tasks for asynchronous execution:

Future a lawful, fast, cancelable alternative to JavaScript's Promise
Scheduler the alternative to using setTimeout for asynchronous boundaries or delayed execution

In support of futures and schedulers, ICancelable data types are introduced for dealing with cancellation concerns:

ICancelable and Cancelable for expressing actions that can be triggered to cancel processes / dispose of resources
IBoolCancelable and BoolCancelable for cancelable references that can be queried for their isCanceled status
IAssignCancelable and AssignCancelable for cancelable references that can be assigned (behave like a box for) another reference
MultiAssignCancelable being a mutable cancelable whose underlying reference can be updated multiple times
SingleAssignCancelable for building forward references, much like MultiAssignCancelable except that it can be assigned only once, triggering an error on the second attempt
SerialCancelable being like a MultiAssignCancelable that cancels its previous underlying reference on updates

And also types for expressing durations:

TimeUnit inspired by Java's own enumeration, representing time
Duration inspired by Scala's own type, as a type safe representation for durations

funfix-effect

npm

Defines monadic data types for controlling laziness, asynchrony and side effects. Exposes the most advanced IO implementation for JavaScript.

See JSDoc documentation.

Quick Overview & Usage
npm install --save funfix-effect

The exposed data types:

Eval lawful, lazy, monadic data type, that can control evaluation, inspired by the Eval type in Typelevel Cats and by the Coeval type in Monix, a more simple IO-like type that can only handle immediate execution, no async boundaries, no error handling, not being meant for suspending side effects.
IO lawful, lazy, monadic data type, capable of expressing and composing side effectful actions, including asynchronous, being the most potent and capable alternative to JavaScript's Promise, inspired by Haskell's IO and by the Monix Task

TypeScript or Flow?

Funfix supports both TypeScript and Flow type annotations out of the box.

It also makes the best use of the capabilities of each. For example TypeScript has bivariant generics, but Flow supports variance annotations and Funfix makes use of them. Development happens in TypeScript, due to better tooling, but both are first class citizens.

Contributing

The Funfix project welcomes contributions from anybody wishing to participate. All code or documentation that is provided must be licensed with the same license that Funfix is licensed with (Apache 2.0).

Feel free to open an issue if you notice a bug, have an idea for a feature, or have a question about the code. Pull requests are also gladly accepted. For more information, check out the contributor guide.

License

All code in this repository is licensed under the Apache License, Version 2.0. See LICENCE.

funland.js's People

Contributors

alexandru avatar dwhitney avatar goodmind avatar greenkeeper[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

funland.js's Issues

Add Semigroup

I'd like to add Semigroup Monoid and Group, but I'm going to do a trial run with just Semigroup to make sure you like my PR. I'll submit it shortly and begin work on Monoid and Group

An in-range update of @types/lodash is breaking the build 🚨

The devDependency @types/lodash was updated from 4.14.117 to 4.14.118.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

@types/lodash is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

An in-range update of tsc-watch is breaking the build 🚨

The devDependency tsc-watch was updated from 1.0.27 to 1.0.28.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

tsc-watch is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 2 commits.

  • ae2f5a8 version 1.0.28
  • 271cb8c command execution args extraction changed to 'string-argv'

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of babel7 is breaking the build 🚨

There have been updates to the babel7 monorepo:

    • The devDependency @babel/core was updated from 7.3.3 to 7.3.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

This monorepo update includes releases of one or more dependencies which all belong to the babel7 group definition.

babel7 is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of jsverify is breaking the build 🚨

The devDependency jsverify was updated from 0.8.3 to 0.8.4.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

jsverify is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 25 commits.

  • 48ba3e5 Release 0.8.4
  • 5d40ead Merge pull request #277 from jsverify/updates-2018-10-31
  • 85384bf Disable node 6 on travis
  • b8338f4 grammar fix in arbitrary.smap documentation
  • 5325c1d Duplicate i.e. i.e.
  • f2a35e9 Update .travis.yml
  • 005f113 Update 2018-10-31
  • 28be14f Merge pull request #270 from SydneyUniLibrary-Jim/issue-242
  • 261b45d Fixed TypeScript bindings for either.
  • b1f63f5 Merge pull request #267 from jsverify/travis-node-ver
  • f99de9a Adjust node versions
  • e018582 Update ts-node
  • 0d392dd Merge pull request #247 from xtianjohns/jasmine-helpers
  • 6f96085 Generate readme
  • 6e0b0ba Remove outdated Jasmine reference in readme

There are 25 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of rimraf is breaking the build 🚨

The devDependency rimraf was updated from 2.6.2 to 2.6.3.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

rimraf is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Commits

The new version differs by 6 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.