Question about Do notation
Basically, I have some experiences with FP-TS and I playing around with Effect-TS, below is the code I playing with Do notation
But the typescript complaint
I also not get any chance by wrap
I even do the simplest thing in this context:
It still error
Please help
const program = pipe(
Effect.Do,
// error next line
Effect.bind('connIdToSocket', () => Ref.make(Map.empty<string, SocketStream>())),
Effect.bind('clientIdToConnId', () => Ref.make(Map.empty<string, string[]>())),
Effect.flatMap(({connIdToSocket, clientIdToConnId}) => {
// do something with connIdToSocket and clientIdToConnId
})
)const program = pipe(
Effect.Do,
// error next line
Effect.bind('connIdToSocket', () => Ref.make(Map.empty<string, SocketStream>())),
Effect.bind('clientIdToConnId', () => Ref.make(Map.empty<string, string[]>())),
Effect.flatMap(({connIdToSocket, clientIdToConnId}) => {
// do something with connIdToSocket and clientIdToConnId
})
)But the typescript complaint
Argument of type '<R, E>(self: Effect<R, E, unknown>) => Effect<R, E, { connIdToSocket: Ref<MutableHashMap<string, SocketStream>>; }>' is not assignable to parameter of type '(a: (_: void) => Effect<never, never, {}>) => Effect<unknown, unknown, { connIdToSocket: Ref<MutableHashMap<string, SocketStream>>; }>'.
Types of parameters 'self' and 'a' are incompatible.
Type '(_: void) => Effect<never, never, {}>' is not assignable to type 'Effect<unknown, unknown, unknown>'.ts(2345)Argument of type '<R, E>(self: Effect<R, E, unknown>) => Effect<R, E, { connIdToSocket: Ref<MutableHashMap<string, SocketStream>>; }>' is not assignable to parameter of type '(a: (_: void) => Effect<never, never, {}>) => Effect<unknown, unknown, { connIdToSocket: Ref<MutableHashMap<string, SocketStream>>; }>'.
Types of parameters 'self' and 'a' are incompatible.
Type '(_: void) => Effect<never, never, {}>' is not assignable to type 'Effect<unknown, unknown, unknown>'.ts(2345)I also not get any chance by wrap
Ref.makeRef.make with Effect.succeedEffect.succeedI even do the simplest thing in this context:
const program = pipe(
Effect.Do,
Effect.bind('connIdToSocket', () => Effect.succeed(1))
// Effect.bind('clientIdToConnId', () => Ref.make(Map.empty<string, string[]>())),
// Effect.flatMap(({connIdToSocket, clientIdToConnId}) => {
// // do something with connIdToSocket and clientIdToConnId
// })
)const program = pipe(
Effect.Do,
Effect.bind('connIdToSocket', () => Effect.succeed(1))
// Effect.bind('clientIdToConnId', () => Ref.make(Map.empty<string, string[]>())),
// Effect.flatMap(({connIdToSocket, clientIdToConnId}) => {
// // do something with connIdToSocket and clientIdToConnId
// })
)It still error
Argument of type '<R, E>(self: Effect<R, E, unknown>) => Effect<R, E, { connIdToSocket: number; }>' is not assignable to parameter of type '(a: (_: void) => Effect<never, never, {}>) => Effect<unknown, unknown, { connIdToSocket: number; }>'.
Types of parameters 'self' and 'a' are incompatible.
Type '(_: void) => Effect<never, never, {}>' is not assignable to type 'Effect<unknown, unknown, unknown>'.ts(2345)Argument of type '<R, E>(self: Effect<R, E, unknown>) => Effect<R, E, { connIdToSocket: number; }>' is not assignable to parameter of type '(a: (_: void) => Effect<never, never, {}>) => Effect<unknown, unknown, { connIdToSocket: number; }>'.
Types of parameters 'self' and 'a' are incompatible.
Type '(_: void) => Effect<never, never, {}>' is not assignable to type 'Effect<unknown, unknown, unknown>'.ts(2345)Please help
