We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to define generic aliases?
I would like to have something like alias AB(T) = T | Tuple(AB(T), AB(T)) to represent Haskell like, binary trees.
alias AB(T) = T | Tuple(AB(T), AB(T))
The text was updated successfully, but these errors were encountered:
Example I want to generalize:
# alias AB(T) = T | Tuple(AB(T), AB(T)) alias ABInt = Int32 | Tuple(ABInt, ABInt) def fold(e : ABInt, fLeaf : Int32 -> T, fRec : Proc(T, T, T)) : T case e when Int32 fLeaf.call(e) when Tuple(ABInt, ABInt) rec1 = fold(e.fst, fLeaf, fRec) rec2 = fold(e.snd, fLeaf, fRec) fRec.call(rec1, rec2) else raise "type Error" end end struct Tuple def fst self[0].not_nil! end def snd self[1].not_nil! end end puts fold( {1, {2, 3}}, ->(n : Int32){n}, ->(reci : Int32, recd : Int32){reci + recd } )
Sorry, something went wrong.
Duplicate of #2803 :-)
No branches or pull requests
Is it possible to define generic aliases?
I would like to have something like
alias AB(T) = T | Tuple(AB(T), AB(T))
to represent Haskell like, binary trees.The text was updated successfully, but these errors were encountered: