Last active
February 26, 2017 18:27
-
-
Save hakuch/484ea9c4e4baaf7b3ab6 to your computer and use it in GitHub Desktop.
OCaml monads: candy dispenser example
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
open Printf | |
let () = | |
let open Candy_dispenser in | |
let dispenser = make ~candies:10 ~coins:3 in | |
let (candies, coins) = dispenser |> run [Insert_coin; Turn; Insert_coin; Turn; Turn] in | |
printf "Got %d candies remaining with %d coins.\n" candies coins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment