Last active
August 16, 2016 19:00
-
-
Save pvillega/11072d57eb7550ad51a4c9a948cf3a1c to your computer and use it in GitHub Desktop.
Can we return just Xor[String, Boolean] and skip the List?
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
// If I have a very simple program | |
def example2(venue: String, account: String) = for { | |
_ <- info("blah blah").freeko[API, O] // Returns Unit | |
b <- buy(venue, account, Order("BAD", -1, -1)).freeko[API, O] // Returns Result[OrderStatus] | |
} yield b | |
// with API definition and Onion | |
type Result[A] = Xor[String, A] | |
type API = LogApi.PRG :||: TradeApi.PRG | |
val API = Program[API] | |
type O = Result[?] :&: List :&: Bulb | |
// And run an interpreter to monix.Task and then execute task via runAsync | |
val result2 = run(example2(testVenue, testAccount)) | |
println("Result 2: " + result2) | |
// $ result2 is of type Xor.Right[List[OrderStatus] | |
// Is there a way to get Xor.Right[OrderStatus] instead? I guess no due to the Onion, but I may have missed something... | |
// I'm not considering 'peeling' the onion as this is a minimal snippet to show what I mean, it can be a longer one where | |
// peeling makes things cumbersome | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment