【发布时间】:2014-11-23 01:26:48
【问题描述】:
在 haskell 中你可以这样做:
type Parser a = String -> [(a, String)]
我尝试在 Swift 中制作类似的东西。到目前为止,我没有运气编写这些代码。
typealias Parser<A> = String -> [(A, String)]
typealias Parser a = String -> [(a, String)]
typealias Parser = String -> [(A, String)]
那么这在 swift 中是不可能的吗?如果是,还有其他方法可以实现这种行为吗?
更新: swift 3 现在似乎支持通用类型别名 https://github.com/apple/swift/blob/master/CHANGELOG.md
【问题讨论】: