On Sun, 2008-05-18 at 21:16 +0400, Bulat Ziganshin wrote: > Hello Derek, > > Sunday, May 18, 2008, 9:10:38 PM, you wrote: > > This is incorrect. There are two (other) situations where you need type > > annotations in Haskell 98. One situation is when you use polymorphic > > recursion, but that is pretty rare unless you are writing nested data > > types > > can you give examples?
-- untested -- all type annotations are necessary -- A nested data type example data PerfectTree a = Leaf a | Succ (PerfectTree (a,a)) size :: PerfectTree a -> Int size (Leaf _) = 1 size (Succ t) = 2 * size t -- a toy example without nested data types f :: Show a => Int -> a -> String f 0 x = show x f n x = f (n-1) (x,x) -- a less toy example bitReverse :: [a] -> [a] bitReverse [x] = [x] bitReverse xs = uncurry (++) . unzip . bitReverse . pairUp $ xs where pairUp [] = [] pairUp (x:y:xs) = (x,y):pairUp xs _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe