Created
September 17, 2012 18:16
-
-
Save hexx/3738873 to your computer and use it in GitHub Desktop.
Start Scalaz2 Exercise2
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
def get[K, V](k: K)(m: Map[K, V]): String \?/ V = | |
try { | |
m(k).success | |
} catch { | |
case e: Throwable => e.getMessage.failure | |
} | |
def user(m: Map[String, String]): NonEmptyList[String] \?/ User = | |
(get("id")(m).toValidationNEL |@| get("age")(m).flatMap(parseInt).toValidationNEL)((id, age) => User(id, age.toInt)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment