[Haskell-cafe] Interleaving type variables in a tree, has this a name ?

Eric Dedieu papa.eric at free.fr
Sat Oct 13 23:25:26 CEST 2012

Hi Haskell Helpers,

For a hobby projet to learn haskell, I'm trying to use this kind of interleaved
tree structure (simplified):

> data ANode a b = ANode a [BNode a b] [BNode a b]
> data BNode a b = BNode b [ANode a b] [ANode a b]

The first list of each node is for links "up", the second for "down".
I can navigate with functions like:

> type UpRank   = Int -- index in the list of nodes
> type DownRank = Int
> upA   :: UpRank -> ANode a b -> Maybe (BNode a b, DownRank)
> downB :: DownRank -> BNode a b -> Maybe (ANode a b, UpRank)

Such as going first up then down leads me to the same point (actually
this simplified structure is not enough to do this, but is enough to
show my problem simply). Thee are also of course upB and downA.

More information about the Haskell-Cafe mailing list