Created
January 11, 2021 09:25
-
-
Save richard-gibson/e97e7824dfe80a658077f339730cfee7 to your computer and use it in GitHub Desktop.
This file contains 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
fun <T> queryUser(s: T?) = | |
Either.fromNullable(s).mapLeft { "unknown" } | |
data class Person(val name: String, val age: Int) | |
val ePerson: Either<String, Person> = Either.applicative<String>().mapN( | |
queryUser("name"), | |
queryUser(10) | |
) { (name, age) -> Person(name, age) }.fix() | |
val aPerson = Either.applicative<String>().just(Person("foo", 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment