PROPOSAL: Restrict the type of (^), (^^), and add genericPower, genericPower'

Ian Lynagh igloo at
Sat Nov 17 11:59:02 EST 2007

On Sat, Nov 17, 2007 at 11:45:52AM -0500, Cale Gibbard wrote:
> On 17/11/2007, Ian Lynagh <igloo at> wrote:
> >
> >     (^)          :: (Num a)             => a -> Int -> a
> >     genericPower :: (Num a, Integral b) => a -> b   -> a
> This is a move in the opposite direction from what I'd really like to
> see. The Int type is usually a premature optimisation, and I usually
> prefer to work with Integer as much as possible, but this just means
> more fromIntegral conversions (or the use of the awkwardly named
> general version).
> I would much prefer for length, !!, etc. to have more general types,
> not less general (with compiler specialisation on Int of course).

This proposal is about making (^) and (^^) consistent with everything
else. Making everything use Integer rather than Int is an orthogonal

Someone could also make a Prelude.Integer module, that exports
    foo :: ... Integer ...
    foo = genericFoo
for various foo which are specialised to Int in Prelude, and reexports
all other functions from Prelude. Getting rid of implicit Prelude
imports would help too.


More information about the Libraries mailing list