
14 Oct
2012
14 Oct
'12
4:45 p.m.
data ANode a b = ANode a [BNode a b] [BNode a b] data BNode a b = BNode b [ANode a b] [ANode a b]
Wouldn't the following work as well and be simpler to handle :
data Node a b = Node a [Node b a] [Node b a]
Yes ! In fact my actual structure is not symmetrical (some lists must preserve order and store additional information for that, some not, and one is a Maybe), so I "naturally" used two distinct node types. When I simplified it for the post, it became symmetrical... Yet I think you're right: if I made it symmetrical (and more general), I would gain much by using your suggestion (and I could also define e.g. Foldable (Node a) which would nicely work a all levels). Thanks.