Last active
August 29, 2015 14:07
-
-
Save JonCanning/3ce59061babf4caef5c3 to your computer and use it in GitHub Desktop.
Reader Monad
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
| let logs = ["Awesome";"Win";"Mathematical";"Skill"] | |
| let (>>=) m k r = (m r, r) ||> k | |
| let add1 i (logs : string list) = | |
| let result = i + 1 | |
| logs.[result] |> printfn "%s" | |
| result | |
| let add2 i (logs : string list) = | |
| let result = i + 2 | |
| logs.[result] |> printfn "%s" | |
| result | |
| let sub1 i (logs : string list) = | |
| let result = i - 1 | |
| logs.[result] |> printfn "%s" | |
| result | |
| add1 -1 >>= add1 >>= add2 >>= sub1 <| logs |> printfn "%i" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment