Skip to content

Commit

Permalink
Merge pull request #164 from armanbilge/pr/cleanup-syntax
Browse files Browse the repository at this point in the history
Cleanup syntax
  • Loading branch information
armanbilge authored Jan 25, 2023
2 parents 5102243 + 7a6c651 commit 2eb6389
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions calico/src/main/scala/calico/syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,5 @@ extension [F[_], A](signal: Signal[F, A])
def get = signal.get

extension [F[_], A](sigRef: SignallingRef[F, A])
def zoom[B <: AnyRef](lens: Lens[A, B])(using Sync[F]): SignallingRef[F, B] =
val ref = Ref.lens[F, A, B](sigRef)(lens.get(_), a => b => lens.replace(b)(a))
new:
def access = ref.access
def modify[C](f: B => (B, C)) = ref.modify(f)
def modifyState[C](state: State[B, C]) = ref.modifyState(state)
def tryModify[C](f: B => (B, C)) = ref.tryModify(f)
def tryModifyState[C](state: State[B, C]) = ref.tryModifyState(state)
def tryUpdate(f: B => B) = ref.tryUpdate(f)
def update(f: B => B) = ref.update(f)
def set(b: B) = ref.set(b)
def get = ref.get
def continuous = sigRef.map(lens.get).continuous
def discrete = sigRef.map(lens.get).discrete

extension [F[_], A, B](pipe: Pipe[F, A, B])
def channel(using F: Concurrent[F]): Resource[F, Channel[F, A]] =
for
ch <- Channel.unbounded[F, A].toResource
_ <- ch.stream.through(pipe).compile.drain.background
yield ch
def zoom[B](lens: Lens[A, B])(using Functor[F]): SignallingRef[F, B] =
SignallingRef.lens[F, A, B](sigRef)(lens.get(_), a => b => lens.replace(b)(a))

0 comments on commit 2eb6389

Please sign in to comment.