hello, i want convert "Either" to a tree. Example: Either ( Either 1 2 ) ( Either 3 4) ---- > Branch ( Branch (Leafl 1) (Leafr2) ) ( Branch (Leafl 3) (Leafr4)) )
Code: data TreeE a b = Empty |Leafl a | Leafr b | Branch (TreeE a b ) (TreeE a b) deriving Show f3 (Right b) (Branch l r) =case( isRight(b) || isLeft(b) )of true -> Branch l (f3 b r) false -> Branch l (Leafl b) f3 (Left b) (Branch l r) = case( isRight(b) || isLeft(b) )of true -> Branch (f3 b l) r false -> Branch (Leafl b) r Error: Occurs check: cannot construct the infinite type: b = Either a b Expected type: Either a b -> TreeE t t1 -> TreeE t t1 Inferred type: Either a (Either a b) -> TreeE t t1 -> t2 In the second argument of `Branch', namely `(f3 b r)' In the expression: Branch l (f3 b r) I don't understand why this happen... Can anyone help me?
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe