diff options
Diffstat (limited to 'src/utils/parser-comb.ts')
| -rw-r--r-- | src/utils/parser-comb.ts | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/utils/parser-comb.ts b/src/utils/parser-comb.ts index 49f633e..e0665f6 100644 --- a/src/utils/parser-comb.ts +++ b/src/utils/parser-comb.ts @@ -1,16 +1,5 @@ -import { Enum, constructors, match } from './adt'; - -export type Result<V, E> = Enum<{ Ok: V, Err: E }> -export const Result = constructors<Result<any, any>>() - -export const mapResult = <A, B, E>(res: Result<A, E>, fn: (_: A) => B): Result<B, E> => - chainResult(res, a => Result.Ok(fn(a))) - -export const chainResult = <A, B, E>(res: Result<A, E>, fn: (_: A) => Result<B, E>): Result<B, E> => - match(res, { - Ok: a => fn(a), - Err: e => Result.Err(e), - }); +import { match } from './adt'; +import { Result, mapResult, chainResult } from './result'; export type ParseResult<T> = Result<{ value: T, input: string }, { error: string, input: string }>; |
