[project @ 2000-11-03 16:23:37 by simonmar]
[ghc-hetmet.git] / ghc / tests / deSugar / should_compile / ds040.hs
1 module ShouldCompile where
2
3 -- !!! Another bug in overloaded n+k patts
4 --
5
6 main  = print ((4::Int) ^^^^ (6::Int))
7
8 (^^^^)          :: (Num a, Integral b) => a -> b -> a
9 x ^^^^ 0                =  1
10 x ^^^^ (n+1)    =  f x n x
11                    where f _ 0 y = y
12                          f x n y = g x n  where
13                                    g x n | even n  = g (x*x) (n `quot` 2)
14                                          | otherwise = f x (n-1) (x*y)
15 _ ^^^^ _                = error "(^^^^){Prelude}: negative exponent"