Skip to content

Instantly share code, notes, and snippets.

@mbrandonw
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save mbrandonw/2b43aabb0c62ca9d36ca to your computer and use it in GitHub Desktop.

Select an option

Save mbrandonw/2b43aabb0c62ca9d36ca to your computer and use it in GitHub Desktop.
func unit <A, B> (f: A -> () -> B) -> (A -> B) {
return { a in
return f(a)()
}
}
extension Int {
func square () -> Int {
return self * self
}
}
Int.square(2)() // 4
unit(Int.square)(2) // 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment