summaryrefslogtreecommitdiff
path: root/testsuite/tests/deSugar/should_compile/ds040.hs
blob: cbef54794f4c1e3068b9056fe3829e25a0da55a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

{-# LANGUAGE NPlusKPatterns #-}

module ShouldCompile where

-- !!! Another bug in overloaded n+k patts
--

main  = print ((4::Int) ^^^^ (6::Int))

(^^^^)          :: (Num a, Integral b) => a -> b -> a
x ^^^^ 0                =  1
x ^^^^ (n+1)    =  f x n x
                   where f _ 0 y = y
                         f x n y = g x n  where
                                   g x n | even n  = g (x*x) (n `quot` 2)
                                         | otherwise = f x (n-1) (x*y)
_ ^^^^ _                = error "(^^^^){Prelude}: negative exponent"