powerAcc のコードが推敲前のものになっていました。本当に書きたかったのは次のコードです。

powerAcc :: (Integral a) => (t -> t -> t) -> t -> a -> t -> t
powerAcc _ _ 0 r = r
powerAcc op x n r = powerAcc op (op x x) (div n 2) r'
    where r' = if odd n then op r x else r

返信