News for hackers. Stuff that matters.
Re:Introduction to Golang by drdaeman on Sunday August 18, 2013 @07:58PM (#6234824)
Sure, I can `type Tree struct { Child []*Tree; Node NodeType }`, where `NodeType` is either `interface{}` (makes `Tree` reusable by sacrificing type safety) or some concrete type (sacrifices `Tree`'s reuse) but that's about how far I can progress. Also, I have to manually ensure that only one of Child or Node is set, but not both.

I just can't do anything like `data Tree a = Leaf a | Node [Tree a]` there.

(Edit: okay, my mind swayed a bit, that was trees, not graphs. I had different ideas on data structure to use, and my memories are a bit messy. Sorry about this. The problem should still hold, it applies to both trees and graphs, and I think many other data structures too.)

Re:Introduction to Golang by cdoxsey on Sunday August 18, 2013 @08:17PM (#6234883)
The 'one of Child or Node' isn't really an issue since you probably shouldn't expose the members of the struct (the tree should be accessed via methods). But I agree with your point about containers.