Skip to content

Instantly share code, notes, and snippets.

@igstan
Last active April 23, 2017 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igstan/b786d870eb28d7e73dcf5223771db6c4 to your computer and use it in GitHub Desktop.
Save igstan/b786d870eb28d7e73dcf5223771db6c4 to your computer and use it in GitHub Desktop.
indirect enum Type: CustomStringConvertible {
case Int
case Fun(Type, Type)
var isFun: Bool {
switch self {
case .Fun: return true
case _: return false
}
}
var description: String {
switch self {
case .Int: return "int"
case .Fun(let p, let r) where p.isFun: return "(\(p)) -> \(r)"
case .Fun(let p, let r): return "(\(p) -> \(r))"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment