data P = Zero | Succ P deriving (Show, Read, Eq)
(.+.) :: P -> P -> P
Zero .+. y = y
Succ x .+. y = Succ (x .+. y)
one :: P
one = Succ Zero
two :: P
two = Succ one
toInt :: P -> Int
toInt Zero = 0
toInt (Succ x) = 1 + toInt x
fromInt :: Int -> P
fromInt 0 = Zero
fromInt i = Succ $ fromInt (i - 1)
main = do
print $ Zero .+. Zero
print $ one .+. one
print $ one .+. one == two
print $ toInt $ two .+. one
print $ fromInt 5