Desugar scala code snippet 23 in chapter 3.4 (#297)

Co-authored-by: Anton Macmillan-Parks <anton.macmillanparks@clearscore.com>
This commit is contained in:
amacmillanparks 2023-02-09 14:23:55 +00:00 committed by GitHub
parent ca3b232e9b
commit 32743b2738
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,8 @@
def words: String => List[String] =
_.split("\\s+").toList
def process: String => Writer[String, List[String]] =
s => {
import bindSyntax._
for {
upStr <- upCase(s)
_ <- tell("toWords ")
} yield words(upStr)
upCase(s).flatMap { upStr =>
tell("toWords ").flatMap { _ =>
writerMonad.pure(words(upStr))
}
}
}