Last active
September 20, 2019 06:19
-
-
Save adamw/b73e667506f810af00bd288ce6a03b0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Re-useable effect descriptions | |
val sendEmail: IO[Unit] = IO(println("Sending email")) | |
val insertUser: ConnectionIO[Int] = | |
sql"INSERT INTO users(name, email) VALUES('Emily', '[email protected]')" | |
.update.run | |
// (1) BEGIN; INSERT; sendEmail(); COMMIT; | |
val insertThenSend: ConnectionIO[Unit] = | |
insertUser.flatMap(_ => sendEmail.to[ConnectionIO]) | |
val result1: IO[Unit] = insertThenSend.transact(transactor) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment