{-# OPTIONS -fglasgow-exts #-}
module Where (tests) where
import Test.HUnit
import Data.Generics
import Control.Monad
data T1 = T1a Int | T1b T2 deriving (Typeable, Data)
data T2 = T2 T1 deriving (Typeable, Data)
stepid (T1a 42) = T1a 88
stepid x = x
stepfail (T1a 42) = Just (T1a 88)
stepfail _ = Nothing
recovered x = mkM stepfail x `mplus` Just x
term42 = T1b (T2 (T1a 42))
term37 = T1b (T2 (T1a 37))
result1 = everywhere (mkT stepid) term42
result2 = everywhere (mkT stepid) term37
result3 = everywhereM (mkM stepfail) term42
result4 = everywhereM (mkM stepfail) term37
result5 = everywhereM recovered term37
result6 = somewhere (mkMp stepfail) term42
result7 = somewhere (mkMp stepfail) term37
tests = gshow ( result1,
( result2,
( result3,
( result4,
( result5,
( result6,
( result7 ))))))) ~=? output
output = "((,) (T1b (T2 (T1a (88)))) ((,) (T1b (T2 (T1a (37)))) ((,) (Nothing) ((,) (Nothing) ((,) (Just (T1b (T2 (T1a (37))))) ((,) (Just (T1b (T2 (T1a (88))))) (Nothing)))))))"