Skip to content

Commit

Permalink
clean up Cause
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMaglione committed Mar 22, 2024
1 parent a44fed8 commit 0f91eeb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
7 changes: 0 additions & 7 deletions packages/fpdart/lib/src/effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ final class Effect<E, L, R> extends IEffect<E, L, R> {
(exit) => switch (exit) {
Left(value: final cause) => switch (cause) {
Fail<L>(error: final error) => Right(error),
Empty() => Left(cause),
Die() => Left(cause),
},
Right(value: final value) => Left(Fail(value)),
Expand All @@ -319,7 +318,6 @@ final class Effect<E, L, R> extends IEffect<E, L, R> {
(exit) => switch (exit) {
Left(value: final cause) => switch (cause) {
Fail<L>(error: final error) => Left(Fail(f(error))),
Empty() => Left(cause),
Die() => Left(cause),
},
Right(value: final value) => Right(value),
Expand All @@ -334,7 +332,6 @@ final class Effect<E, L, R> extends IEffect<E, L, R> {
(exit) => switch (exit) {
Left(value: final cause) => switch (cause) {
Fail<L>(error: final error) => Left(Fail(fl(error))),
Empty() => Left(cause),
Die() => Left(cause),
},
Right(value: final value) => Right(fr(value)),
Expand Down Expand Up @@ -364,7 +361,6 @@ final class Effect<E, L, R> extends IEffect<E, L, R> {
Fail<L>(error: final error) => f(error)._unsafeRun(env).then(
(_) => Left(Fail(error)),
),
Empty() => Left(cause),
Die() => Left(cause),
},
Right(value: final value) => Right(value),
Expand All @@ -381,7 +377,6 @@ final class Effect<E, L, R> extends IEffect<E, L, R> {
(exit) => switch (exit) {
Left(value: final cause) => switch (cause) {
Fail<L>(error: final error) => orElse(error)._unsafeRun(env),
Empty() => Left(cause),
Die() => Left(cause),
},
Right(value: final value) =>
Expand Down Expand Up @@ -409,7 +404,6 @@ final class Effect<E, L, R> extends IEffect<E, L, R> {
Left(value: final cause) => switch (cause) {
Fail<L>(error: final error) =>
Left(Die.current(onError(error))),
Empty() => Left(cause),
Die() => Left(cause),
},
Right(value: final value) =>
Expand All @@ -427,7 +421,6 @@ final class Effect<E, L, R> extends IEffect<E, L, R> {
(exit) => switch (exit) {
Left(value: final cause) => switch (cause) {
Fail<L>(error: final error) => f(error)._unsafeRun(env),
Empty() => Left(cause),
Die() => Left(cause),
},
Right(value: final value) =>
Expand Down
25 changes: 0 additions & 25 deletions packages/fpdart/lib/src/exit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,6 @@ typedef Exit<L, R> = Either<Cause<L>, R>;

sealed class Cause<L> implements Error {
const Cause();
Cause<L> withTrace(StackTrace stack);
}

/// Represents a lack of errors
final class Empty extends Cause<Never> {
@override
final StackTrace? stackTrace;

const Empty([this.stackTrace]);

@override
Empty withTrace(StackTrace stack) => stackTrace == null ? Empty(stack) : this;

@override
String toString() {
return "Cause.Empty()";
}
}

/// Failed as a result of a defect (unexpected error)
Expand All @@ -36,10 +19,6 @@ final class Die extends Cause<Never> {
factory Die.current(dynamic error, [StackTrace? stackTrace]) =>
Die(error, StackTrace.current, stackTrace);

@override
Die withTrace(StackTrace stack) =>
stackTrace == null ? Die(error, defectStackTrace, stack) : this;

@override
bool operator ==(Object other) => (other is Fail) && other.error == error;

Expand All @@ -61,10 +40,6 @@ final class Fail<L> extends Cause<L> {

const Fail(this.error, [this.stackTrace]);

@override
Fail<L> withTrace(StackTrace stack) =>
stackTrace == null ? Fail(error, stack) : this;

@override
bool operator ==(Object other) => (other is Fail) && other.error == error;

Expand Down

0 comments on commit 0f91eeb

Please sign in to comment.