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

Jon Fairbairn jon.fairbairn at cl.cam.ac.uk
Sun Nov 18 06:19:16 EST 2007


"Cale Gibbard" <cgibbard at gmail.com> writes:

> On 17/11/2007, Ian Lynagh <igloo at earth.li> wrote:
>> In my opinion, (^) has the wrong type. Just as we have, for example,
>>     (!!)         ::                 [a] -> Int -> a
>>     genericIndex :: (Integral b) => [a] -> b   -> a
>> we should also have
>>     (^)          :: (Num a)             => a -> Int -> a
>>     genericPower :: (Num a, Integral b) => a -> b   -> a
>> (or some other function name). The same goes for (^^) (genericPower').

> This is a move in the opposite direction from what I'd really like to
> see. The Int type is usually a premature optimisation, 

Hear, hear.

> I would much prefer for length, !!, etc. to have more general types,
> not less general (with compiler specialisation on Int of course).
>
> This change would be annoying.

Agreed.

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk




More information about the Libraries mailing list