UNPKG

monad-ts

Version:

Monad-ts is a small library implements some of key monads and way to chain them in a pipe (flow) in JavaScript and TypeScript. Angular 2+ compatible.

1,314 lines 25.2 kB
{ "type": "File", "start": 0, "end": 944, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 27, "column": 0 } }, "program": { "type": "Program", "start": 0, "end": 944, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 27, "column": 0 } }, "sourceType": "module", "body": [], "directives": [], "leadingComments": null, "innerComments": [ { "type": "CommentLine", "value": " import {MF} from '../types/mf';", "start": 0, "end": 34, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 34 } } }, { "type": "CommentLine", "value": " import {Pr} from '../types/pr';", "start": 36, "end": 70, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 34 } } }, { "type": "CommentLine", "value": " import {D} from '../types/d';", "start": 72, "end": 104, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 32 } } }, { "type": "CommentLine", "value": "", "start": 106, "end": 108, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 2 } } }, { "type": "CommentLine", "value": " /** interface Binding<T>{", "start": 110, "end": 138, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 28 } } }, { "type": "CommentLine", "value": " *", "start": 140, "end": 148, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 8 } } }, { "type": "CommentLine", "value": " * bind<T,U>(f: MF<T, U> | D<T>, v: any): Pr<U> | Error | boolean;", "start": 150, "end": 222, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 72 } } }, { "type": "CommentLine", "value": " *", "start": 224, "end": 232, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 8 } } }, { "type": "CommentLine", "value": " * }", "start": 234, "end": 244, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 10 } } }, { "type": "CommentLine", "value": " * @interface", "start": 246, "end": 262, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 16 } } }, { "type": "CommentLine", "value": " * @name Binding - monads interface to bind transformation function and underlying value to the monad", "start": 264, "end": 368, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 104 } } }, { "type": "CommentLine", "value": " * {@link Maybe}, {@link ErrorM}, {@link Either}, {@link Identity}, {@link List}.", "start": 370, "end": 454, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 12, "column": 84 } } }, { "type": "CommentLine", "value": " * @noimport true", "start": 456, "end": 476, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 13, "column": 20 } } }, { "type": "CommentLine", "value": " **/", "start": 478, "end": 485, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 14, "column": 7 } } }, { "type": "CommentLine", "value": " export class Binding<T> {", "start": 487, "end": 515, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 15, "column": 28 } } }, { "type": "CommentLine", "value": " /**", "start": 517, "end": 527, "loc": { "start": { "line": 16, "column": 0 }, "end": { "line": 16, "column": 10 } } }, { "type": "CommentLine", "value": " * binds transformation function and underlying value to the monad.", "start": 529, "end": 603, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 17, "column": 74 } } }, { "type": "CommentLine", "value": " * @param {MF<T, U> | D<T>} f - transformation function.", "start": 605, "end": 668, "loc": { "start": { "line": 18, "column": 0 }, "end": { "line": 18, "column": 63 } } }, { "type": "CommentLine", "value": " * @param v - underlying value.", "start": 670, "end": 708, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 19, "column": 38 } } }, { "type": "CommentLine", "value": " * @return {Pr<U> | Error | boolean}", "start": 710, "end": 753, "loc": { "start": { "line": 20, "column": 0 }, "end": { "line": 20, "column": 43 } } }, { "type": "CommentLine", "value": " */", "start": 755, "end": 765, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 21, "column": 10 } } }, { "type": "CommentLine", "value": " bind<T,U>(f: MF<T, U> | D<T>, v: any): Pr<U> | Error | boolean{", "start": 767, "end": 837, "loc": { "start": { "line": 22, "column": 0 }, "end": { "line": 22, "column": 70 } } }, { "type": "CommentLine", "value": " return void 0;", "start": 839, "end": 864, "loc": { "start": { "line": 23, "column": 0 }, "end": { "line": 23, "column": 25 } } }, { "type": "CommentLine", "value": " };", "start": 866, "end": 875, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 24, "column": 9 } } }, { "type": "CommentLine", "value": " }", "start": 877, "end": 881, "loc": { "start": { "line": 25, "column": 0 }, "end": { "line": 25, "column": 4 } } }, { "type": "CommentLine", "value": " Copyright (c) 2017 Alex Tranchenko. All rights reserved.", "start": 883, "end": 942, "loc": { "start": { "line": 26, "column": 0 }, "end": { "line": 26, "column": 59 } } } ] }, "comments": [ { "type": "CommentLine", "value": " import {MF} from '../types/mf';", "start": 0, "end": 34, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 34 } } }, { "type": "CommentLine", "value": " import {Pr} from '../types/pr';", "start": 36, "end": 70, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 34 } } }, { "type": "CommentLine", "value": " import {D} from '../types/d';", "start": 72, "end": 104, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 32 } } }, { "type": "CommentLine", "value": "", "start": 106, "end": 108, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 2 } } }, { "type": "CommentLine", "value": " /** interface Binding<T>{", "start": 110, "end": 138, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 28 } } }, { "type": "CommentLine", "value": " *", "start": 140, "end": 148, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 8 } } }, { "type": "CommentLine", "value": " * bind<T,U>(f: MF<T, U> | D<T>, v: any): Pr<U> | Error | boolean;", "start": 150, "end": 222, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 72 } } }, { "type": "CommentLine", "value": " *", "start": 224, "end": 232, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 8 } } }, { "type": "CommentLine", "value": " * }", "start": 234, "end": 244, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 10 } } }, { "type": "CommentLine", "value": " * @interface", "start": 246, "end": 262, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 16 } } }, { "type": "CommentLine", "value": " * @name Binding - monads interface to bind transformation function and underlying value to the monad", "start": 264, "end": 368, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 104 } } }, { "type": "CommentLine", "value": " * {@link Maybe}, {@link ErrorM}, {@link Either}, {@link Identity}, {@link List}.", "start": 370, "end": 454, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 12, "column": 84 } } }, { "type": "CommentLine", "value": " * @noimport true", "start": 456, "end": 476, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 13, "column": 20 } } }, { "type": "CommentLine", "value": " **/", "start": 478, "end": 485, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 14, "column": 7 } } }, { "type": "CommentLine", "value": " export class Binding<T> {", "start": 487, "end": 515, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 15, "column": 28 } } }, { "type": "CommentLine", "value": " /**", "start": 517, "end": 527, "loc": { "start": { "line": 16, "column": 0 }, "end": { "line": 16, "column": 10 } } }, { "type": "CommentLine", "value": " * binds transformation function and underlying value to the monad.", "start": 529, "end": 603, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 17, "column": 74 } } }, { "type": "CommentLine", "value": " * @param {MF<T, U> | D<T>} f - transformation function.", "start": 605, "end": 668, "loc": { "start": { "line": 18, "column": 0 }, "end": { "line": 18, "column": 63 } } }, { "type": "CommentLine", "value": " * @param v - underlying value.", "start": 670, "end": 708, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 19, "column": 38 } } }, { "type": "CommentLine", "value": " * @return {Pr<U> | Error | boolean}", "start": 710, "end": 753, "loc": { "start": { "line": 20, "column": 0 }, "end": { "line": 20, "column": 43 } } }, { "type": "CommentLine", "value": " */", "start": 755, "end": 765, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 21, "column": 10 } } }, { "type": "CommentLine", "value": " bind<T,U>(f: MF<T, U> | D<T>, v: any): Pr<U> | Error | boolean{", "start": 767, "end": 837, "loc": { "start": { "line": 22, "column": 0 }, "end": { "line": 22, "column": 70 } } }, { "type": "CommentLine", "value": " return void 0;", "start": 839, "end": 864, "loc": { "start": { "line": 23, "column": 0 }, "end": { "line": 23, "column": 25 } } }, { "type": "CommentLine", "value": " };", "start": 866, "end": 875, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 24, "column": 9 } } }, { "type": "CommentLine", "value": " }", "start": 877, "end": 881, "loc": { "start": { "line": 25, "column": 0 }, "end": { "line": 25, "column": 4 } } }, { "type": "CommentLine", "value": " Copyright (c) 2017 Alex Tranchenko. All rights reserved.", "start": 883, "end": 942, "loc": { "start": { "line": 26, "column": 0 }, "end": { "line": 26, "column": 59 } } } ], "tokens": [ { "type": "CommentLine", "value": " import {MF} from '../types/mf';", "start": 0, "end": 34, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 34 } } }, { "type": "CommentLine", "value": " import {Pr} from '../types/pr';", "start": 36, "end": 70, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 34 } } }, { "type": "CommentLine", "value": " import {D} from '../types/d';", "start": 72, "end": 104, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 32 } } }, { "type": "CommentLine", "value": "", "start": 106, "end": 108, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 2 } } }, { "type": "CommentLine", "value": " /** interface Binding<T>{", "start": 110, "end": 138, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 28 } } }, { "type": "CommentLine", "value": " *", "start": 140, "end": 148, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 8 } } }, { "type": "CommentLine", "value": " * bind<T,U>(f: MF<T, U> | D<T>, v: any): Pr<U> | Error | boolean;", "start": 150, "end": 222, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 7, "column": 72 } } }, { "type": "CommentLine", "value": " *", "start": 224, "end": 232, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 8, "column": 8 } } }, { "type": "CommentLine", "value": " * }", "start": 234, "end": 244, "loc": { "start": { "line": 9, "column": 0 }, "end": { "line": 9, "column": 10 } } }, { "type": "CommentLine", "value": " * @interface", "start": 246, "end": 262, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 10, "column": 16 } } }, { "type": "CommentLine", "value": " * @name Binding - monads interface to bind transformation function and underlying value to the monad", "start": 264, "end": 368, "loc": { "start": { "line": 11, "column": 0 }, "end": { "line": 11, "column": 104 } } }, { "type": "CommentLine", "value": " * {@link Maybe}, {@link ErrorM}, {@link Either}, {@link Identity}, {@link List}.", "start": 370, "end": 454, "loc": { "start": { "line": 12, "column": 0 }, "end": { "line": 12, "column": 84 } } }, { "type": "CommentLine", "value": " * @noimport true", "start": 456, "end": 476, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 13, "column": 20 } } }, { "type": "CommentLine", "value": " **/", "start": 478, "end": 485, "loc": { "start": { "line": 14, "column": 0 }, "end": { "line": 14, "column": 7 } } }, { "type": "CommentLine", "value": " export class Binding<T> {", "start": 487, "end": 515, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 15, "column": 28 } } }, { "type": "CommentLine", "value": " /**", "start": 517, "end": 527, "loc": { "start": { "line": 16, "column": 0 }, "end": { "line": 16, "column": 10 } } }, { "type": "CommentLine", "value": " * binds transformation function and underlying value to the monad.", "start": 529, "end": 603, "loc": { "start": { "line": 17, "column": 0 }, "end": { "line": 17, "column": 74 } } }, { "type": "CommentLine", "value": " * @param {MF<T, U> | D<T>} f - transformation function.", "start": 605, "end": 668, "loc": { "start": { "line": 18, "column": 0 }, "end": { "line": 18, "column": 63 } } }, { "type": "CommentLine", "value": " * @param v - underlying value.", "start": 670, "end": 708, "loc": { "start": { "line": 19, "column": 0 }, "end": { "line": 19, "column": 38 } } }, { "type": "CommentLine", "value": " * @return {Pr<U> | Error | boolean}", "start": 710, "end": 753, "loc": { "start": { "line": 20, "column": 0 }, "end": { "line": 20, "column": 43 } } }, { "type": "CommentLine", "value": " */", "start": 755, "end": 765, "loc": { "start": { "line": 21, "column": 0 }, "end": { "line": 21, "column": 10 } } }, { "type": "CommentLine", "value": " bind<T,U>(f: MF<T, U> | D<T>, v: any): Pr<U> | Error | boolean{", "start": 767, "end": 837, "loc": { "start": { "line": 22, "column": 0 }, "end": { "line": 22, "column": 70 } } }, { "type": "CommentLine", "value": " return void 0;", "start": 839, "end": 864, "loc": { "start": { "line": 23, "column": 0 }, "end": { "line": 23, "column": 25 } } }, { "type": "CommentLine", "value": " };", "start": 866, "end": 875, "loc": { "start": { "line": 24, "column": 0 }, "end": { "line": 24, "column": 9 } } }, { "type": "CommentLine", "value": " }", "start": 877, "end": 881, "loc": { "start": { "line": 25, "column": 0 }, "end": { "line": 25, "column": 4 } } }, { "type": "CommentLine", "value": " Copyright (c) 2017 Alex Tranchenko. All rights reserved.", "start": 883, "end": 942, "loc": { "start": { "line": 26, "column": 0 }, "end": { "line": 26, "column": 59 } } }, { "type": { "label": "eof", "beforeExpr": false, "startsExpr": false, "rightAssociative": false, "isLoop": false, "isAssign": false, "prefix": false, "postfix": false, "binop": null, "updateContext": null }, "start": 944, "end": 944, "loc": { "start": { "line": 27, "column": 0 }, "end": { "line": 27, "column": 0 } } } ] }