data Tree a = Leaf a | Node (Tree a) (Tree a) deriving (Generic)The derived instance of Out is equivalent to:
instance (Out a) => Out (Tree a) where docPrec d (Leaf m) = Pretty.sep $ wrapParens (d > appPrec) $ text "Leaf" : [nest (constrLen + parenLen) (docPrec (appPrec+1) m)] where appPrec = 10 constrLen = 5; parenLen = if(d > appPrec) then 1 else 0 docPrec d (Node u v) = Pretty.sep $ wrapParens (d > appPrec) $ text "Node" : nest (constrLen + parenLen) (docPrec (appPrec+1) u) : [nest (constrLen + parenLen) (docPrec (appPrec+1) v)] where appPrec = 10 constrLen = 5 parenLen = if(d > appPrec) then 1 else 0
outdegree (buildG (0,-1) []) == array (0,-1) []
outdegree (buildG (0,2) [(0,1), (1,2)]) == array (0,2) [(0,1),(1,1),(2,0)]