Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Commit

Permalink
fix mapBoth signature in transformResult example (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
fubhy authored Aug 9, 2023
1 parent c0d97e7 commit 76664ca
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1123,8 +1123,6 @@ The transformation may also be async:
import * as S from "@effect/schema/Schema";
import * as PR from "@effect/schema/ParseResult";
import * as Effect from "@effect/io/Effect";
import fetch from "node-fetch";
import { pipe } from "@effect/data/Function";
import * as TF from "@effect/schema/TreeFormatter";

const api = (url: string) =>
Expand All @@ -1145,11 +1143,10 @@ const PeopleIdFromString = S.transformResult(
S.string,
PeopleId,
(s) =>
Effect.mapBoth(
api(`https://swapi.dev/api/people/${s}`),
(e) => PR.parseError([PR.type(PeopleId.ast, s, e.message)]),
() => s
),
Effect.mapBoth(api(`https://swapi.dev/api/people/${s}`), {
onFailure: (e) => PR.parseError([PR.type(PeopleId.ast, s, e.message)]),
onSuccess: () => s
}),
PR.success
);

Expand Down

0 comments on commit 76664ca

Please sign in to comment.