Last active
December 13, 2018 03:33
-
-
Save iboss-ptk/6466e8c92c63703ad8a8f747f4f49cf3 to your computer and use it in GitHub Desktop.
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
| data class ContextA(val valueA: String, val valueB: Int) | |
| data class ContextB(val valueB: Int, val valueC: Int, val valueD: Double) | |
| val theReader: Reader<Int, String> = | |
| Reader().lift { b: Int -> "The number is $b!!!" } | |
| val theReaderInA: Reader<ContextA, String> = theReader | |
| .local(ContextA::valueB::get) | |
| val theReaderInB: Reader<ContextB, String> = theReader | |
| .local(ContextB::valueB::get) | |
| theReaderInA | |
| .runId(ContextA(valueA = "I'm string", valueB = 1)) | |
| // => The number is 1!!! | |
| theReaderInB | |
| .runId(ContextB(valueB = 3, valueC = 1, valueD = 1.3)) | |
| // => The number is 3!!! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment