diff --git a/typescript/option/src/helpers.ts b/typescript/option/src/helpers.ts index cba4003..68c35c3 100644 --- a/typescript/option/src/helpers.ts +++ b/typescript/option/src/helpers.ts @@ -7,8 +7,7 @@ import { BackFolder, Nullable } from './internalTypes' -import { identity } from './internalHelperts' -import { none, some } from './internals' +import { identity, none, some } from './internals' export const isSome = (option: Option) => option._type === some export const isNothing = (option: Option) => option._type === none diff --git a/typescript/option/src/internalHelperts.ts b/typescript/option/src/internalHelperts.ts deleted file mode 100644 index d1600f3..0000000 --- a/typescript/option/src/internalHelperts.ts +++ /dev/null @@ -1 +0,0 @@ -export const identity = (v: T) => v diff --git a/typescript/option/src/internals.ts b/typescript/option/src/internals.ts index 0b62f3d..0e16212 100644 --- a/typescript/option/src/internals.ts +++ b/typescript/option/src/internals.ts @@ -1,7 +1,4 @@ -export const some = 'some' -export const none = 'none' +export const identity = (v: T) => v -export type NominalTyped = { - _type: T - value: U -} +export const some = Symbol('some') +export const none = Symbol('none') diff --git a/typescript/option/src/types.ts b/typescript/option/src/types.ts index ce2a5d5..e1e15af 100644 --- a/typescript/option/src/types.ts +++ b/typescript/option/src/types.ts @@ -1,16 +1,21 @@ -import { NominalTyped, none, some } from './internals' +import { some, none } from './internals' -export type None = NominalTyped<'none', null> -export type Some = NominalTyped<'some', T> +type NominalTyped = { + _type: T + value: U +} + +export type None = NominalTyped +export type Some = NominalTyped export type Option = Some | None export const None: Option = { - _type: 'none', + _type: none, value: null } export const Some = (value: T): Option => ({ - _type: 'some', + _type: some, value })