Public feed #603609

Unnamed

public text v1 · immutable
Raw Edit
·published 2007-07-04 22:37 UTC
rendered paste body
{-# OPTIONS_GHC -fglasgow-exts #-}
import Data.Generics

data Blah = Foo String | Blah String deriving (Eq, Show, Data, Typeable)

stuff :: IO [Blah]
stuff = rec [Foo "foo", Blah "blah"]
    where
      rec :: Data a => a -> IO a
      rec = gmapM (extM handleOther handleString)
      handleString :: String -> IO String
      handleString i = putStrLn ("Hi! The string was " ++ i) >> return ("Changed " ++ i)
      handleOther :: Data b => b -> IO b
      handleOther = gmapM rec

main :: IO ()
main = putStrLn . show =<< stuff