
On Sat, Nov 17, 2007 at 01:00:51PM -0500, Cale Gibbard wrote:
On 17/11/2007, Ian Lynagh
wrote: On Sat, Nov 17, 2007 at 11:45:52AM -0500, Cale Gibbard wrote:
On 17/11/2007, Ian Lynagh
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.
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.
You can also make Prelude.Generic foo :: Integral a => ... a ... foo = genericFoo Or we could just remove the genericFoo functions and have Prelude.Generic.foo be the canonical name. If possible, I would like to separate what we should do /in general/ from whether we should make (^) and (^^) consistent with the rest of the libraries, though. If someone wants to propose a change to the general scheme /now/ then I don't mind this proposal waiting until that is either resolved or fizzles out. Thanks Ian