Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// https://github.com/fantasyland/fantasy-land#applicative | ||
export interface IApplicative<T> { | ||
ap<V>(afn: IApplicative<(val: T) => V>): IApplicative<V> | ||
'fantasy-land/ap'<V>(afn: IApplicative<(val: T) => V>): IApplicative<V> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// TypeClass for catamorphism | ||
export interface ICatamorphism<F, T> { | ||
cata<C>(l: (e?: F) => C, r: (v: T) => C): C | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// https://github.com/fantasyland/fantasy-land#chain | ||
export interface IChain<T> { | ||
chain<V>(fn: (val: T) => IChain<V>): IChain<V> | ||
'fantasy-land/chain'<V>(fn: (val: T) => IChain<V>): IChain<V> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// https://github.com/fantasyland/fantasy-land#functor | ||
export interface IFunctor<T> { | ||
map<V>(fn: (val: T) => V): IFunctor<V> | ||
'fantasy-land/map'<V>(fn: (val: T) => V): IFunctor<V> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from './applicative' | ||
export * from './catamorphism' | ||
export * from './chain' | ||
export * from './functor' | ||
export * from './monad' | ||
export * from './setoid' | ||
export * from './traversable' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { IApplicative } from './applicative' | ||
import { IChain } from './chain' | ||
import { IFunctor } from './functor' | ||
|
||
interface IMonad<T> extends IFunctor<T>, IChain<T>, IApplicative<T> { | ||
readonly ['@@type']: string | ||
bind<V>(fn: (val: T) => IMonad<V>): IMonad<V> | ||
flatMap<V>(fn: (val: T) => IMonad<V>): IMonad<V> | ||
chain<V>(fn: (val: T) => IMonad<V>): IMonad<V> | ||
map<V>(fn: (val: T) => V): IMonad<V> | ||
join<V>(): IMonad<V> // only if T = IMonad<V> | ||
/* These are monet-Monad-specific: */ | ||
takeLeft(m: IMonad<T>): IMonad<T> | ||
takeRight(m: IMonad<T>): IMonad<T> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// https://github.com/fantasyland/fantasy-land#setoid | ||
export interface ISetoid<A> { | ||
equals(other: A): boolean | ||
['fantasy-land/equals'](other: A): boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// TypeClass for traversables | ||
export interface ITraversable<T> { | ||
foldLeft<V>(initial: V): (fn: (acc: V, val: T) => V) => V | ||
foldRight<V>(initial: V): (fn: (val: T, acc: V) => V) => V | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './data' | ||
export * from './helpers' |