Skip to content

Instantly share code, notes, and snippets.

@volodg
Created March 16, 2020 07:45
Show Gist options
  • Save volodg/e4dc4d7bfb6b8f605e6248a38d058bf1 to your computer and use it in GitHub Desktop.
Save volodg/e4dc4d7bfb6b8f605e6248a38d058bf1 to your computer and use it in GitHub Desktop.
exchangeFilters.foldRight(IO.pure(exchanges)) { (filter, exchange) =>
for {
exchange <- exchange
result <- filter.processResult(exchange, productDetails)
} yield result
}
@volodg
Copy link
Author

volodg commented Mar 16, 2020

Or even better

import cats.implicits._

def processResult(productDetails: ProductDetails)(exchanges: List[Exchange]): IO[List[Exchange]]

exchangeFilters.foldRight(IO.pure(exchanges)) { (filter, exchange) =>
  exchange >>= filter.processResult(productDetails)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment