Variante A (explizite Implementierung)
data Tree a = Leaf | Branch { left :: Tree a
, key :: a , right :: Tree a }
instance Serial a => Serial ( Tree a ) where
series = cons0 Leaf \/ cons3 Branch
Variante B (automatische Implementierung)
{-# LANGUAGE DeriveGeneric #-}
import Test.SmallCheck
import GHC.Generics
data Tree a = Leaf | Branch { left :: Tree a
, key :: a , right :: Tree a }
deriving Generics
instance Serial a => Serial (Tree a)