Skip to content

Commit

Permalink
fix: remove external exposure of None and Some
Browse files Browse the repository at this point in the history
Can simplify some of the typescript contracts by making the `some` and
`none` methods return type `Maybe` instead of types `Some` and `None`
respectively. This will make the TS types use the more generic `Maybe`
versions instead of the specific classes.
  • Loading branch information
andy.patterson authored and andnp committed Apr 12, 2018
1 parent 74d26dc commit 19ad1ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/none.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Maybe, { MatchType, Nil } from "./maybe";
import Maybe, { MatchType } from "./maybe";
import { maybe } from "index";

export default class None<T> extends Maybe<T> {
Expand All @@ -20,11 +20,11 @@ export default class None<T> extends Maybe<T> {
this as any;
}

map<U>(f: (v: T) => (U | Nil)): Maybe<U> {
map<U>(): Maybe<U> {
return this as any;
}

flatMap<U>(f: (v: T) => Maybe<U>): Maybe<U> {
flatMap<U>(): Maybe<U> {
return this as any;
}

Expand All @@ -43,4 +43,4 @@ export default class None<T> extends Maybe<T> {
asNullable(): T | null { return null; }
}

export const none = None.none;
export const none: <T>() => Maybe<T> = None.none;
2 changes: 1 addition & 1 deletion src/some.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ export default class Some<T> extends Maybe<T> {
}
}

export const some = Some.some;
export const some: <T>(x: T) => Maybe<T> = Some.some;

0 comments on commit 19ad1ff

Please sign in to comment.