Skip to content

Commit

Permalink
renamed succeedLazy and failLazy
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMaglione committed Apr 4, 2024
1 parent 43f0592 commit 2f80240
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/fpdart_http/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() async {
)
.timeout(Duration(milliseconds: 1300))
.tap(
(response) => Effect.functionSucceed(
(response) => Effect.succeedLazy(
() => print(response.body),
),
)
Expand Down
2 changes: 1 addition & 1 deletion examples/poke_api/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void main() async {
final exit = await program("9722")
.map((pokemon) => print(pokemon))
.catchError<void>(
(error) => Effect.functionSucceed(
(error) => Effect.succeedLazy(
() => print("No pokemon: $error"),
),
)
Expand Down
2 changes: 1 addition & 1 deletion packages/fpdart/lib/src/deferred.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ final class Deferred<L, R> {
}

Effect<E, C, Unit> completeExit<E, C>(Exit<L, R> exit) =>
Effect.functionSucceed(() {
Effect.succeedLazy(() {
switch (_state) {
case None():
unsafeCompleteExit(exit);
Expand Down
4 changes: 2 additions & 2 deletions packages/fpdart/lib/src/effect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ final class Effect<E, L, R> extends IEffect<E, L, R> {
);

/// {@category constructors}
factory Effect.functionFail(FutureOr<Cause<L>> Function() f) => Effect.from(
factory Effect.failLazy(FutureOr<Cause<L>> Function() f) => Effect.from(
(_) => f().then(Left.new),
);

/// {@category constructors}
factory Effect.functionSucceed(FutureOr<R> Function() f) => Effect.from(
factory Effect.succeedLazy(FutureOr<R> Function() f) => Effect.from(
(_) => f().then(Right.new),
);

Expand Down
6 changes: 3 additions & 3 deletions packages/fpdart/lib/src/scope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ mixin ScopeMixin {
Effect<E, L, Unit> addScopeFinalizer<E, L>(
Effect<Null, Never, Unit> finalizer,
) =>
Effect.functionSucceed(() {
Effect.succeedLazy(() {
scopeFinalizers.add(finalizer);
return unit;
});

Effect<E, L, Unit> removeScopeFinalizer<L, E>(
Effect<Null, Never, Unit> finalizer,
) =>
Effect.functionSucceed(() {
Effect.succeedLazy(() {
scopeFinalizers.remove(finalizer);
return unit;
});

Effect<E, L, Unit> closeScope<E, L>() => Effect.lazy(
() => scopeFinalizers.reversed.all.zipRight(Effect.functionSucceed(
() => scopeFinalizers.reversed.all.zipRight(Effect.succeedLazy(
() {
scopeFinalizers.clear();
return unit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void main() {
final main = Effect.all<Null, String, int>([
Effect.succeed(10),
Effect.fail("10"),
Effect.functionSucceed(() => mutable += 1),
Effect.succeedLazy(() => mutable += 1),
Effect.fail("0"),
]);
final result = main.flip().runSync();
Expand Down
4 changes: 2 additions & 2 deletions packages/fpdart/test/src/effect/effect_constructors_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void main() {
test('async succeed', () async {
final main = Effect<Null, Never, int>.gen(($) async {
final value =
await $.async(Effect.functionSucceed(() => Future.value(10)));
await $.async(Effect.succeedLazy(() => Future.value(10)));
return value;
});
final result = await main.runFuture();
Expand All @@ -82,7 +82,7 @@ void main() {

test('fail when running async as sync', () async {
final main = Effect<Null, Never, int>.gen(($) {
final value = $.sync(Effect.functionSucceed(
final value = $.sync(Effect.succeedLazy(
() async => Future.value(10),
));
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void main() {
() {
group('catchCause', () {
test('recover from throw', () {
final result = Effect<Null, Never, String>.functionSucceed(() {
final result = Effect<Null, Never, String>.succeedLazy(() {
throw "fail";
})
.catchCause(
Expand Down
8 changes: 4 additions & 4 deletions packages/fpdart/test/src/effect/effect_scoping_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ void main() {
var mutable = 0;
final main =
Effect<Null, String, int>.succeed(10).withScope.addFinalizer(
Effect.functionSucceed(() {
Effect.succeedLazy(() {
mutable += 1;
return unit;
}),
Expand All @@ -26,7 +26,7 @@ void main() {
var mutable = 0;
final main =
Effect<bool, String, int>.succeed(10).withScope.addFinalizer(
Effect.functionSucceed(() {
Effect.succeedLazy(() {
mutable += 1;
return unit;
}),
Expand All @@ -43,7 +43,7 @@ void main() {
var mutable = 0;
final main = Effect<Null, String, int>.succeed(10)
.acquireRelease(
(r) => Effect.functionSucceed(() {
(r) => Effect.succeedLazy(() {
mutable = r;
return unit;
}),
Expand All @@ -58,7 +58,7 @@ void main() {
var mutable = 0;
final main = Effect<Null, String, int>.fail("error")
.acquireRelease(
(r) => Effect.functionSucceed(() {
(r) => Effect.succeedLazy(() {
mutable = r;
return unit;
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void main() {
test('tap', () {
var mutable = 0;
final main = Effect<Null, String, int>.succeed(10).tap(
(_) => Effect.functionSucceed(() {
(_) => Effect.succeedLazy(() {
mutable += 1;
}),
);
Expand Down

0 comments on commit 2f80240

Please sign in to comment.