Skip to content

Instantly share code, notes, and snippets.

@LeifW
Created August 23, 2018 03:21
Show Gist options
  • Save LeifW/779a0825e501d43b95062d5804738082 to your computer and use it in GitHub Desktop.
Save LeifW/779a0825e501d43b95062d5804738082 to your computer and use it in GitHub Desktop.
Do-notation desugaring in Idris
-- Apply the callback that is the rest of the lines of code
(>>=) : Int -> (Int -> Int) -> Int
(>>=) x f = f x
i : Int
i = do
x <- 1
y <- 2
x + y
-- Or with effect syntax.
j : Int
j = !1 + 2
@LeifW
Copy link
Author

LeifW commented Aug 23, 2018

General version of that >>= is:

(>>=) : a -> (a -> b) -> b
x >>= f = f x

(which is just flip apply)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment