←back to thread

42 points todsacerdoti | 2 comments | | HN request time: 0.424s | source
1. molikto ◴[] No.42190849[source]
convertTree doesn't work because Tree uses Tree type recursively.
replies(1): >>42194123 #
2. jerf ◴[] No.42194123[source]
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.