Service Dependency in Schema
Is there any way to have a service dependency in a schema?
// I have this
import { normalize as path_normalize } from 'node:path';
const NormalizedPathSchema = S.transform(
S.string,
S.string,
(path) => path_normalize(path),
identity,
);
// But would like to do this
import * as Path from '@effect/platform/Path';
const NormalizedPathSchema = S.transformResult(
S.string,
S.string,
// Type error
// Type 'Effect<Path, never, string>' is not assignable to type 'ParseResult<string>'.
// Type 'Path' is not assignable to type 'never'.ts(2322)
(path) => T.gen(function* (_) {
const { normalize } = yield* _(Path.Path);
return normalize(path);
}),
T.succeed,
);// I have this
import { normalize as path_normalize } from 'node:path';
const NormalizedPathSchema = S.transform(
S.string,
S.string,
(path) => path_normalize(path),
identity,
);
// But would like to do this
import * as Path from '@effect/platform/Path';
const NormalizedPathSchema = S.transformResult(
S.string,
S.string,
// Type error
// Type 'Effect<Path, never, string>' is not assignable to type 'ParseResult<string>'.
// Type 'Path' is not assignable to type 'never'.ts(2322)
(path) => T.gen(function* (_) {
const { normalize } = yield* _(Path.Path);
return normalize(path);
}),
T.succeed,
);