mirror of
https://github.com/hmemcpy/milewski-ctfp-pdf.git
synced 2024-10-05 18:17:16 +03:00
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:
parent
ca3b232e9b
commit
32743b2738
@ -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))
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user