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

Cale Gibbard cgibbard at gmail.com
Sat Nov 17 13:00:51 EST 2007


On 17/11/2007, Ian Lynagh <igloo at earth.li> wrote:
> On Sat, Nov 17, 2007 at 11:45:52AM -0500, Cale Gibbard wrote:
> > On 17/11/2007, Ian Lynagh <igloo at earth.li> 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
> question.
>
> 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.
>
>
> Thanks
> Ian

I don't want the types specialised to Integer either though. I'd want
to have the types be as generic as possible, but include appropriate
pragmas to tell GHC how to optimise when they're applied
monomorphically.


More information about the Libraries mailing list