Last active
July 2, 2016 09:46
-
-
Save ukitaka/e64768007244816dfd27e78964560f0d to your computer and use it in GitHub Desktop.
Haskell.swift
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
func const<A, B>(a: A) -> B -> A { | |
return { _ in a } | |
} |
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
func curry<A, B>(_ function: (A) -> B) -> (A) -> B { | |
return { (`a`: A) -> B in function(`a`) } | |
} | |
func curry<A, B, C>(_ function: (A, B) -> C) -> (A) -> (B) -> C { | |
return { (`a`: A) -> (B) -> C in { (`b`: B) -> C in function(`a`, `b`) } } | |
} | |
func curry<A, B, C, D>(_ function: (A, B, C) -> D) -> (A) -> (B) -> (C) -> D { | |
return { (`a`: A) -> (B) -> (C) -> D in { (`b`: B) -> (C) -> D in { (`c`: C) -> D in function(`a`, `b`, `c`) } } } | |
} |
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
func id<A>(a: A) -> A { | |
return a | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment