0.2.0 #5

Merged
Thilawyn merged 59 commits from next into master 2026-05-30 06:10:54 +02:00
Showing only changes of commit c3b375ddc3 - Show all commits
+38 -22
View File
@@ -49,7 +49,7 @@ extends Pipeable.Class() implements Lens<A, ER, EW, RR, RW> {
abstract readonly resolve: Effect.Effect<LensImpl.Frame<A, EW, RW>, ER, RR>
abstract readonly changes: Stream.Stream<A, ER, RR>
abstract readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, EW | E1, RW | R1>
abstract readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, E1, R1>
get get() { return Effect.map(this.resolve, frame => frame.value) }
@@ -82,7 +82,7 @@ export declare namespace LensLazyImpl {
readonly get: Effect.Effect<A, ER, RR>
readonly changes: Stream.Stream<A, ER, RR>
readonly commit: (a: A) => Effect.Effect<void, EW, RW>
readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, EW | E1, RW | R1>
readonly withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, E1, R1>
}
}
@@ -129,7 +129,10 @@ export declare namespace DerivedLensImpl {
in out RSW = never,
> {
readonly resolve: (effect: Effect.Effect<LensImpl.Frame<B, ESW, RSW>, ESR, RSR>) => Effect.Effect<LensImpl.Frame<A, EW, RW>, ER, RR>
readonly transformStream: (stream: Stream.Stream<B, ESR, RSR>) => Stream.Stream<A, ER, RR>
readonly mapStream: (stream: Stream.Stream<B, ESR, RSR>) => Stream.Stream<A, ER, RR>
readonly withLock: (
withLock: <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, E1, R1>
) => <A1, E1, R1>(self: Effect.Effect<A1, E1, R1>) => Effect.Effect<A1, E1, R1>
}
}
@@ -154,8 +157,8 @@ extends LensImpl<A, ER, EW, RR, RW> {
}
get resolve() { return this.source.resolve(this.parent.resolve) }
get changes() { return this.source.transformStream(this.parent.changes) }
get withLock() { return this.parent.withLock }
get changes() { return this.source.mapStream(this.parent.changes) }
get withLock() { return this.source.withLock(this.parent.withLock) }
}
/**
@@ -322,25 +325,26 @@ export const map: {
<A, ER, EW, RR, RW, B>(
self: Lens<A, ER, EW, RR, RW>,
get: (a: NoInfer<A>) => B,
update: (a: NoInfer<A>, b: B) => NoInfer<A>,
set: (a: NoInfer<A>, b: B) => NoInfer<A>,
): Lens<B, ER, EW, RR, RW>
<A, ER, EW, RR, RW, B>(
get: (a: NoInfer<A>) => B,
update: (a: NoInfer<A>, b: B) => NoInfer<A>,
set: (a: NoInfer<A>, b: B) => NoInfer<A>,
): (self: Lens<A, ER, EW, RR, RW>) => Lens<B, ER, EW, RR, RW>
} = Function.dual(3, <A, ER, EW, RR, RW, B>(
self: Lens<A, ER, EW, RR, RW>,
get: (a: NoInfer<A>) => B,
update: (a: NoInfer<A>, b: B) => NoInfer<A>,
set: (a: NoInfer<A>, b: B) => NoInfer<A>,
): Lens<B, ER, EW, RR, RW> => derive(self, {
resolve: parent => Effect.map(
parent,
frame => ({
value: get(frame.value),
commit: next => frame.commit(Effect.map(next, b => update(frame.value, b))),
commit: next => frame.commit(Effect.map(next, b => set(frame.value, b))),
}),
),
transformStream: Stream.map(get),
mapStream: Stream.map(get),
withLock: identity,
}))
/**
@@ -371,7 +375,8 @@ export const mapEffect: {
}),
),
),
transformStream: Stream.mapEffect(get),
mapStream: Stream.mapEffect(get),
withLock: identity,
}))
/**
@@ -456,7 +461,8 @@ export const mapStream: {
f: (changes: Stream.Stream<NoInfer<A>, NoInfer<ER>, NoInfer<RR>>) => Stream.Stream<NoInfer<A>, NoInfer<ER>, NoInfer<RR>>,
): Lens<A, ER, EW, RR, RW> => derive(self, {
resolve: identity,
transformStream: f,
mapStream: f,
withLock: identity,
}))
@@ -478,7 +484,8 @@ export const mapErrorRead: {
f: (error: NoInfer<ER>) => E2,
): Lens<A, E2, EW, RR, RW> => derive(self, {
resolve: Effect.mapError(f),
transformStream: Stream.mapError(f),
mapStream: Stream.mapError(f),
withLock: identity,
}))
/**
@@ -506,7 +513,8 @@ export const mapErrorWrite: {
value => Effect.mapError(frame.commit(Effect.succeed(value)), f),
),
})),
transformStream: identity,
mapStream: identity,
withLock: identity,
}))
/**
@@ -537,7 +545,8 @@ export const mapError: {
),
}),
),
transformStream: Stream.mapError(f),
mapStream: Stream.mapError(f),
withLock: identity,
}))
/**
@@ -561,7 +570,8 @@ export const catchAllRead: {
parent,
error => asLensImpl(f(error)).resolve as Effect.Effect<LensImpl.Frame<A, EW | EW2, RW | RW2>, E2, R2>,
),
transformStream: Stream.catchAll(error => f(error).changes),
mapStream: Stream.catchAll(error => f(error).changes),
withLock: identity,
} as DerivedLensImpl.Source<A, A, E2, ER, EW | EW2, EW, RR | R2, RR, RW | RW2, RW>))
/**
@@ -588,7 +598,8 @@ export const catchAllWrite: {
value => Effect.catchAll(frame.commit(Effect.succeed(value)), f),
),
})),
transformStream: identity,
mapStream: identity,
withLock: identity,
}))
/**
@@ -609,7 +620,8 @@ export const tapErrorRead: {
f: (error: NoInfer<ER>) => Effect.Effect<unknown, E2, R2>,
): Lens<A, ER | E2, EW, RR | R2, RW> => derive(self, {
resolve: Effect.tapError(f),
transformStream: Stream.tapError(f),
mapStream: Stream.tapError(f),
withLock: identity,
}))
/**
@@ -637,7 +649,8 @@ export const tapErrorWrite: {
value => Effect.tapError(frame.commit(Effect.succeed(value)), f),
),
})),
transformStream: identity,
mapStream: identity,
withLock: identity,
}))
/**
@@ -668,7 +681,8 @@ export const tapError: {
),
}),
),
transformStream: Stream.tapError(f),
mapStream: Stream.tapError(f),
withLock: identity,
}))
@@ -694,7 +708,8 @@ export const provideContext: {
commit: next => Effect.provide(frame.commit(Effect.provide(next, context)), context),
}),
),
transformStream: Stream.provideSomeContext(context),
mapStream: Stream.provideSomeContext(context),
withLock: parentWithLock => self => Effect.provide(parentWithLock(Effect.provide(self, context)), context),
}))
/**
@@ -725,7 +740,8 @@ export const provideService: {
commit: next => Effect.provideService(frame.commit(Effect.provideService(next, tag, service)), tag, service),
}),
),
transformStream: Stream.provideService(tag, service),
mapStream: Stream.provideService(tag, service),
withLock: parentWithLock => self => Effect.provideService(parentWithLock(Effect.provideService(self, tag, service)), tag, service),
}))