Skip to content

Commit

Permalink
re-use Pure instance
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Apr 30, 2023
1 parent da3429e commit 23d889a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion shared/src/main/scala/org/atnos/eff/Eff.scala
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ trait EffCreation {
/** attach a clean-up action to the continuation (if any) */
def whenStopped[R, A](e: Eff[R, A], action: Last[R]): Eff[R, A] =
e match {
case Pure(a, l) => Pure(a, l)
case x @ Pure(_, _) => x
case Impure(u, c, l) => Impure(u, c.copy(onNone = c.onNone <* action), l)
case ImpureAp(u, c, l) => ImpureAp(u, c.copy(onNone = c.onNone <* action), l)
}
Expand Down
4 changes: 2 additions & 2 deletions shared/src/main/scala/org/atnos/eff/SubscribeEffect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ object SubscribeEffect {
}

e match {
case Pure(a, last) =>
Pure(a, last)
case x @ Pure(_, _) =>
x

case Impure(NoEffect(a), c, last) =>
memoizeSubsequence(key, sequenceKey, subSequenceKey, cache, c(a).addLast(last))
Expand Down

0 comments on commit 23d889a

Please sign in to comment.