サバじゃねえ! 2みたいになっています。
- そのままなぞっても型エラーでうまくいかないので、toOptionでMaybe型→Option型にしておく
- getMaybe is deprecated
Monocle/Prism.scala at 4bebf15f825d593ff25287903d9b2dfe2ea972e1 · julien-truffaut/Monocle · GitHub
package com.example import monocle.Prism import scalaz.Maybe object Hello { def main(args: Array[String]): Unit = { val strToInt = Prism[String, Int] { str: String => Maybe.fromTryCatchNonFatal(str.toInt).toOption }(_.toString) println(strToInt.getMaybe("3")) println(strToInt.getMaybe("")) // getMaybe is deprecated println("Hello, world!") } }