Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:alexandru/funfix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandru committed Aug 21, 2017
2 parents 85b2967 + 0ebad3b commit 5ecc37c
Show file tree
Hide file tree
Showing 42 changed files with 99 additions and 135 deletions.
96 changes: 32 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,86 +26,54 @@ The code is organized in ES2015 modules, but all types,
classes and functions are exported by the
[root module](https://funfix.org/api/modules/_funfix_.html).

**["core"](https://funfix.org/api/modules/_core_index_.html)**
---
**[core](https://funfix.org/api/modules/_core_index_.html)**
defines core data types and universal interfaces:

- **[Option<A>](https://funfix.org/api/classes/_core_disjunctions_.option.html)**:
data type for representing optional values, much like the "`Maybe`"
monadic type from Haskell or "`Option`" from Scala
- **[Either<L,R>](https://funfix.org/api/classes/_core_disjunctions_.either.html)**:
data type for representing disjoint unions, for working with values of
two possible types, inspired by the data type with the same name
from Haskell and Scala
- **[Try<A>](https://funfix.org/api/classes/_core_disjunctions_.try.html)**:
data type for capturing exceptional results and manipulating
them as values, being equivalent in spirit with `Either<Throwable, A>`,
inspired by the data type with the same name from Scala
- **[core/errors](https://funfix.org/api/modules/_core_errors_.html)**:
sub-module that defines the standard `Error` types
- **[core/std](https://funfix.org/api/modules/_core_std_.html)**:
sub-module that defines the `IEquals` interface for structural equality,
along with other utilities
| | |
|:------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Option&lt;A&gt;](https://funfix.org/api/classes/_core_disjunctions_.option.html) | data type for representing optional values, much like the "`Maybe`" monadic type from Haskell or "`Option`" from Scala |
| [Either&lt;L,R&gt;](https://funfix.org/api/classes/_core_disjunctions_.either.html) | data type for representing disjoint unions, for working with values of two possible types, inspired by the data type with the same name from Haskell and Scala |
| [Try&lt;A&gt;](https://funfix.org/api/classes/_core_disjunctions_.try.html) | data type for capturing exceptional results and manipulating them as values, being equivalent in spirit with `Either<Throwable, A>`, inspired by the data type with the same name from Scala |
| [core/errors](https://funfix.org/api/modules/_core_errors_.html) | sub-module that defines the standard `Error` types |
| [core/std](https://funfix.org/api/modules/_core_std_.html) | sub-module that defines the `IEquals` interface for structural equality, along with other utilities |

---
**["exec"](https://funfix.org/api/modules/_exec_index_.html)** defines low
level primitives for dealing with asynchrony and concurrency:

- **[Future&lt;A&gt;](https://funfix.org/api/classes/_exec_future_.future.html)**:
a lawful and cancelable alternative to JavaScript's `Promise`
- **[DynamicRef&lt;A&gt;](https://funfix.org/api/classes/_exec_ref_.dynamicref.html)**:
binding mechanism for global variables
- **[exec/cancelable](https://funfix.org/api/modules/_exec_cancelable_.html)**:
sub-module that defines `ICancelable` and derived interfaces, classes
and utilities for dealing with cancellation
- **[exec/scheduler](https://funfix.org/api/modules/_exec_scheduler_.html)**:
sub-module that defines `Scheduler`, for scheduling asynchronous
execution, as an alternative to working straight with `setTimeout`
- **[exec/time](https://funfix.org/api/modules/_exec_time_.html)**:
sub-module that defines `TimeUnit` and `Duration` for specifying
timespans
| | |
|:------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Future&lt;A&gt;](https://funfix.org/api/classes/_exec_future_.future.html) | a lawful and cancelable alternative to JavaScript's `Promise` |
| [DynamicRef&lt;A&gt;](https://funfix.org/api/classes/_exec_ref_.dynamicref.html) | binding mechanism for global variables, inspired by Scala's implicits |
| [exec/cancelable](https://funfix.org/api/modules/_exec_cancelable_.html) | sub-module that defines `ICancelable` and derived interfaces, classes and utilities for dealing with cancellation |
| [exec/scheduler](https://funfix.org/api/modules/_exec_scheduler_.html) | sub-module that defines `Scheduler`, for scheduling asynchronous execution, as an alternative to working straight with `setTimeout` |
| [exec/time](https://funfix.org/api/modules/_exec_time_.html) | sub-module that defines `TimeUnit` and `Duration` for specifying timespans |

---
**["effect"](https://funfix.org/api/modules/_effect_index_.html)**
defines data types for dealing with side effects:

- **[Eval&lt;A&gt;](https://funfix.org/api/classes/_effect_eval_.eval.html)**:
data type for suspending synchronous side effects and controlling
evaluation (e.g. memoization, error handling)
| | |
|:------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Eval&lt;A&gt;](https://funfix.org/api/classes/_effect_eval_.eval.html) | data type for suspending synchronous side effects and controlling evaluation (e.g. memoization, error handling) |

---
**["types"](https://funfix.org/api/modules/_types_index_.html)**
defines [type classes](https://en.wikipedia.org/wiki/Type_class)
inspired by Haskell's standard library and by
[Typelevel Cats](http://typelevel.org/cats/):

- **[Eq](https://funfix.org/api/classes/_types_eq_.eq.html)**:
a type class for determining equality between instances of the
same type and that obeys the laws defined in
[EqLaws](https://funfix.org/api/classes/_types_eq_.eqlaws.html)
- **[Functor](https://funfix.org/api/classes/_types_functor_.functor.html)**:
a type class exposing `map` and that obeys the laws defined in
[FunctorLaws](https://funfix.org/api/classes/_types_functor_.functorlaws.html)
- **[Apply](https://funfix.org/api/classes/_types_applicative_.apply.html)**:
a type class that extends `Functor`, exposing `ap` and that obeys
the laws defined in
[ApplyLaws](https://funfix.org/api/classes/_types_apply_.applylaws.html)
- **[Applicative](https://funfix.org/api/classes/_types_applicative_.applicative.html)**:
a type class that extends `Functor` and `Apply`, exposing `pure`
and that obeys the laws defined in
[ApplicativeLaws](https://funfix.org/api/classes/_types_applicative_.applicativelaws.html)
- **[ApplicativeError](https://funfix.org/api/classes/_types_applicative_.applicativeerror.html)**:
a type class that extends `Applicative`, for applicative types that can raise errors
or recover from them and that obeys the laws defined in
[ApplicativeErrorLaws](https://funfix.org/api/classes/_types_applicative_.applicativeerrorlaws.html)
- **[FlatMap](https://funfix.org/api/classes/_types_monad_.flatmap.html)**:
a type class that extends `Functor` and `Apply`, exposing `flatMap`
and `tailRecM` and that obeys the laws defined in
[FlatMapLaws](https://funfix.org/api/classes/_types_monad_.flatmaplaws.html)
- **[Monad](https://funfix.org/api/classes/_types_monad_.monad.html)**:
a type class that extends `Applicative` and `FlatMap`
and that obeys the laws defined in
[MonadLaws](https://funfix.org/api/classes/_types_monad_.monadlaws.html)
- **[MonadError](https://funfix.org/api/classes/_types_monad_.monaderror.html)**:
a type class that extends `ApplicativeError` and `Monad`, for monads that
can raise or recover from errors and that obeys the laws defined in
[MonadErrorLaws](https://funfix.org/api/classes/_types_monad_.monaderrorlaws.html)
| | |
|:------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Eq](https://funfix.org/api/classes/_types_eq_.eq.html) | a type class for determining equality between instances of the same type and that obeys the laws defined in [EqLaws](https://funfix.org/api/classes/_types_eq_.eqlaws.html) |
| [Functor](https://funfix.org/api/classes/_types_functor_.functor.html) | a type class exposing `map` and that obeys the laws defined in [FunctorLaws](https://funfix.org/api/classes/_types_functor_.functorlaws.html) |
| [Apply](https://funfix.org/api/classes/_types_applicative_.apply.html) | a type class that extends `Functor`, exposing `ap` and that obeys the laws defined in [ApplyLaws](https://funfix.org/api/classes/_types_apply_.applylaws.html) |
| [Applicative](https://funfix.org/api/classes/_types_applicative_.applicative.html) | a type class that extends `Functor` and `Apply`, exposing `pure` and that obeys the laws defined in [ApplicativeLaws](https://funfix.org/api/classes/_types_applicative_.applicativelaws.html) |
| [ApplicativeError](https://funfix.org/api/classes/_types_applicative_.applicativeerror.html) | a type class that extends `Applicative`, for applicative types that can raise errors or recover from them and that obeys the laws defined in [ApplicativeErrorLaws](https://funfix.org/api/classes/_types_applicative_.applicativeerrorlaws.html) |
| [FlatMap](https://funfix.org/api/classes/_types_monad_.flatmap.html) | a type class that extends `Functor` and `Apply`, exposing `flatMap` and `tailRecM` and that obeys the laws defined in [FlatMapLaws](https://funfix.org/api/classes/_types_monad_.flatmaplaws.html) |
| [Monad](https://funfix.org/api/classes/_types_monad_.monad.html) | a type class that extends `Applicative` and `FlatMap` and that obeys the laws defined in [MonadLaws](https://funfix.org/api/classes/_types_monad_.monadlaws.html) |
| [MonadError](https://funfix.org/api/classes/_types_monad_.monaderror.html) | a type class that extends `ApplicativeError` and `Monad`, for monads that can raise or recover from errors and that obeys the laws defined in [MonadErrorLaws](https://funfix.org/api/classes/_types_monad_.monaderrorlaws.html) |

More is coming 😉

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"option",
"either"
],
"main": "dist/funfix.umd.js",
"module": "dist/funfix.es5.js",
"typings": "dist/types/funfix.d.ts",
"main": "dist/index.umd.js",
"module": "dist/index.js",
"typings": "dist/types/index.d.ts",
"files": [
"dist",
"src",
Expand Down
13 changes: 5 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,18 @@
* limitations under the License.
*/

import babel from "rollup-plugin-babel"
import resolve from "rollup-plugin-node-resolve"
import commonjs from "rollup-plugin-commonjs"
const babel = require("rollup-plugin-babel")
const resolve = require("rollup-plugin-node-resolve")
const commonjs = require("rollup-plugin-commonjs")

const pkg = require("./package.json")
const { camelCase } = require("lodash")
const typescript = require("rollup-plugin-typescript2")

const libraryName = "funfix"

export default {
entry: `src/${libraryName}.ts`,
entry: `src/index.ts`,
targets: [
{ dest: pkg.main, moduleName: camelCase(libraryName), format: "umd" },
{ dest: pkg.module, format: "es" }
{ dest: pkg.main, moduleName: "funfix", format: "umd" }
],
sourceMap: true,
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
Expand Down
2 changes: 1 addition & 1 deletion rootdoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const email: string | null =
## Features Overview

The code is organized in ES2015 modules, but all types, classes and
functions are exported by the [root module]{@link "funfix"}.
functions are exported by the [root module]{@link "index"}.

**["core"]{@link "core/index"}** defines core
data types and universal interfaces:
Expand Down
2 changes: 1 addition & 1 deletion src/exec/future.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import { Try, Success, Failure, Option, Some, None, Either, Left, Right } from "../core/disjunctions"
import { IllegalStateError } from "../core/errors"
import { Scheduler } from "./scheduler"
import { ICancelable, SingleAssignCancelable, MultiAssignCancelable } from "./cancelable"
import { ICancelable, Cancelable, MultiAssignCancelable } from "./cancelable"

/**
* `IPromiseLike` represents objects that have a `then` method complying with
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
functorOf,
Left,
Right
} from "../../src/funfix"
} from "../../../src/"

const optLeft: Either<number, string> = Left(1)
const optRight: Either<number, string> = Right("unu")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* @flow */

// Testing wildcard import
import * as ff from "../../src/funfix"
import * as ff from "../../../src/"

// Testing a la carte import
import {
Expand All @@ -28,7 +28,7 @@ import {
IllegalInheritanceError,
IllegalStateError,
IllegalArgumentError
} from "../../src/core"
} from "../../../src/core"

new ff.CompositeError([])
new ff.CompositeError(["error", new Error()])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
monadOf,
Eq,
eqOf
} from "../../src/funfix"
} from "../../../src/"

const opt: Option<number> = Option.of(1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* @flow */

import * as ff from "../../src/funfix"
import * as ff from "../../../src/"
// A la carte import
import {
IEquals,
Expand All @@ -27,7 +27,7 @@ import {
isValueObject,
hashCodeOfString,
applyMixins
} from "../../src/core"
} from "../../../src/core"

// IEquals test (1)
const opt: ff.Option<number> = ff.Option.of(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
Success,
Try,
TryInstances
} from "../../src/funfix"
} from "../../../src/"

const failure: Try<string> = Failure(1)
const success: Try<string> = Success("unu")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

/* @flow */

import * as ff from "../../src/funfix"
import { Try, Right, Either } from "../../src/funfix"
import { Eval } from "../../src/effect"
import * as ff from "../../../src/"
import { Try, Right, Either } from "../../../src/"
import { Eval } from "../../../src/effect"
import {
Functor,
functorOf,
Expand All @@ -32,7 +32,7 @@ import {
Monad,
monadOf,
EvalInstances
} from "../../src/types"
} from "../../../src/types"

const ref1: ff.Eval<number> = ff.Eval.always(() => 1)
const ref2: Eval<number> = Eval.always(() => 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
monadOf,
MonadError,
monadErrorOf
} from "../../src/funfix"
} from "../../../src/"

const fa1: Future<number> = Future.pure(1)
const fa2: Future<number> = Future.pure(1, Scheduler.global.get())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* @flow */

import { DynamicRef } from "../../src/funfix"
import { DynamicRef } from "../../../src/"

const ref: DynamicRef<string> = DynamicRef.of(() => "original")
const value: string = ref.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
TestScheduler,
Duration,
ICancelable
} from "../../src/funfix"
} from "../../../src/"

const global: Scheduler = Scheduler.global.get()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* @flow */

// Testing a la carte import
import type { OptionK, TypeClass } from "../../src/funfix"
import type { OptionK, TypeClass } from "../../../src/"
import {
Equiv,
Applicative,
Expand All @@ -32,7 +32,7 @@ import {
Option,
Some,
applyMixins
} from "../../src/funfix"
} from "../../../src/"

const erasure: Applicative<any> = Applicative._funErasure
const typeId: string = Applicative._funTypeId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/* @flow */

import type { EvalK, TypeClass } from "../../src/funfix"
import type { EvalK, TypeClass } from "../../../src/"
import {
Equiv,
ApplicativeError,
Expand All @@ -33,7 +33,7 @@ import {
Eval,
Either,
applyMixins
} from "../../src/funfix"
} from "../../../src/"

const erasure: ApplicativeError<any, any> = ApplicativeError._funErasure
const typeId: string = ApplicativeError._funTypeId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* @flow */

// Testing a la carte import
import type { OptionK, TypeClass } from "../../src/funfix"
import type { OptionK, TypeClass } from "../../../src/"
import {
Equiv,
Apply,
Expand All @@ -30,7 +30,7 @@ import {
Option,
Some,
applyMixins
} from "../../src/funfix"
} from "../../../src/"

const erasure: Apply<any> = Apply._funErasure
const typeId: string = Apply._funTypeId
Expand Down
4 changes: 2 additions & 2 deletions test/flow/eq.test.js.flow → test/flow/types/eq.test.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* @flow */

// Testing a la carte import
import type { TypeClass } from "../../src/funfix"
import type { TypeClass } from "../../../src/"
import {
Eq,
EqLaws,
Expand All @@ -28,7 +28,7 @@ import {
Some,
None,
applyMixins
} from "../../src/funfix"
} from "../../../src/"

const erasure: Eq<any> = Eq._funErasure
const typeId: string = Eq._funTypeId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* @flow */

// Testing a la carte import
import type { OptionK, TypeClass } from "../../src/funfix"
import type { OptionK, TypeClass } from "../../../src/"
import {
Equiv,
Functor,
Expand All @@ -33,7 +33,7 @@ import {
Some,
applyMixins,
Either
} from "../../src/funfix"
} from "../../../src/"

const erasure: FlatMap<any> = FlatMap._funErasure
const typeId: string = FlatMap._funTypeId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* @flow */

// Testing a la carte import
import type { OptionK, TypeClass } from "../../src/funfix"
import type { OptionK, TypeClass } from "../../../src/"
import {
Equiv,
Functor,
Expand All @@ -28,7 +28,7 @@ import {
Option,
Some,
applyMixins
} from "../../src/funfix"
} from "../../../src/"

const erasure: Functor<any> = Functor._funErasure
const typeId: string = Functor._funTypeId
Expand Down
Loading

0 comments on commit 5ecc37c

Please sign in to comment.