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
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.
There's a nice approach to this problem which is described
and implemented in the MonadPrompt package[1].
Thanks a lot for this link. The guessing game example linked to from
the documentation is still very hard to understand (I'm still struggling
with monads), but it seems to fill my needs.
Still more importantly to me, I understand that anyhow if I intend
to use IO or random numbers, I must design my strategy from the
beginning as encapsulated in a monad. Something like:
class (Monad m) = Strategy m a where ...
That's not true at all, you can always pass this data
Thanks for your answers. I still have a question, though...
I think the reasoninging here is the following: If MonadState is part
of the standard library and it needs this extension to work, then all
compilers must support this extension.
Yes, exactly, that was my point.
I'm not completely