Created
January 6, 2014 12:08
-
-
Save kazu-yamamoto/8281920 to your computer and use it in GitHub Desktop.
SYB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DeriveDataTypeable #-} | |
module A where | |
import Data.Typeable (Typeable) | |
import Data.Generics (everywhere, mkT, Data) | |
data T = Tree [U] deriving (Show,Data,Typeable) | |
data U = I Int | T T deriving (Show,Data,Typeable) | |
plus1 :: U -> U | |
plus1 (I n) = I (n + 1) | |
plus1 x = x | |
tree :: T | |
tree = Tree [I 1, T (Tree [I 2])] | |
tree2 :: T | |
tree2 = everywhere (mkT plus1) tree | |
{- | |
> tree2 | |
Tree [I 2,T (Tree [I 3])] | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment