I have a simple program that I've been working on:
import * as T from "@effect-ts/core/Effect";
import { pipe } from "@effect-ts/core/Function";
import { tag } from "@effect-ts/core/Has";
interface ConsoleModule {
log: (message: string) => T.UIO<void>;
}
const ConsoleModule = tag<ConsoleModule>();
const log = (m: string) =>
T.accessServiceM(ConsoleModule)((console) => console.log(m));
const program = pipe(
log("hello"),
T.chain(() => log("world"))
);
pipe(
program,
T.provideService(ConsoleModule)({
log: (message) =>
T.effectAsync(() => {
console.log(message);
}),
}),
T.run
);
However, the output only displays “hello” and not “world“. I believe there might be a fundamental misunderstanding in my use of chain
or pipe
.