Re:Nominal for Storing, Structural for Manipulating
by molikto on Tuesday November 19, 2024 @11:35PM
(#42190849)
convertTree doesn't work because Tree uses Tree type recursively.
[ Parent
| on HN ]
Re:Nominal for Storing, Structural for Manipulating
by jerf on Wednesday November 20, 2024 @09:20AM
(#42194123)
Since the author is writing their own language, their language can fix that; it's not hard to figure out how to implement that.
What I find horrifying is that types are most useful when they are more than just a shape. Just because two things have a type X[A] {X[A], A, X[A]} doesn't mean it's the same binary tree. A trivial example is that one tree could be sorting by the "id" field and another could be sorting on a "username" field, and simply casting one to the other means you've now got a garbage data structure and none of the functions/methods operating on it are going to return good data now. It's a bit of a culture shock to see such Haskell-esque type notation combined with excitement over blowing away everything about a type other than its brute shape.