blob: c99f5fab63eba3c671fb6aedff6bdcc78dcc0425 (
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"
|