I think this proposal goes the wrong way.&nbsp; We should not make types more specific, but more general.<br>Instead of ruining ^ and ^^, lets make the type of length, take, etc more general.<br><br>&nbsp; -- Lennart<br><br><div class="gmail_quote">
On Nov 17, 2007 2:02 PM, Ian Lynagh &lt;<a href="mailto:igloo@earth.li">igloo@earth.li</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>Hi all,<br><br>This got a warm reception when I mentioned it in<br> &nbsp; &nbsp;<a href="http://www.haskell.org/pipermail/haskell-cafe/2007-June/027557.html" target="_blank">http://www.haskell.org/pipermail/haskell-cafe/2007-June/027557.html
</a><br>so I&#39;m formally proposing it now. It&#39;s trac #1902:<br> &nbsp; &nbsp;<a href="http://hackage.haskell.org/trac/ghc/ticket/1902" target="_blank">http://hackage.haskell.org/trac/ghc/ticket/1902</a><br><br>Note that this is a divergence from Haskell 98 (but the libraries
<br>already have a handful of small divergences, and Haskell&#39; is just around<br>the corner...).<br><br>In my opinion, (^) has the wrong type. Just as we have, for example,<br> &nbsp; &nbsp;(!!) &nbsp; &nbsp; &nbsp; &nbsp; :: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [a] -&gt; Int -&gt; a
<br> &nbsp; &nbsp;genericIndex :: (Integral b) =&gt; [a] -&gt; b &nbsp; -&gt; a<br>we should also have<br> &nbsp; &nbsp;(^) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:: (Num a) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&gt; a -&gt; Int -&gt; a<br> &nbsp; &nbsp;genericPower :: (Num a, Integral b) =&gt; a -&gt; b &nbsp; -&gt; a
<br>(or some other function name). The same goes for (^^) (genericPower&#39;).<br><br>In my experience this would remove 99.9% of all defaulting (mostly where<br>you write things like x^12 and 8^12), which means it&#39;s easier to get
<br>-Wall clean without having to put :: Int annotations everywhere.<br><br>The impact to GHC&#39;s bootlibs and extralibs is minimal. In most cases we<br>have things like 2^15, where Int is clearly fine, although it happens to
<br>be defaulted to Integer currently. In Data.Complex we have 2 cases of<br>e^(2::Int) which can now be beautified. There are several cases where<br>the type is inferred to be Int anyway.<br><br>There are 3 files where we really do have an Integer, and it does
<br>matter. They are all for parsing numbers of the form 18e43, in<br>base/Text/Read/Lex.hs, parsec/Text/ParserCombinators/Parsec/Token.hs and<br>haskell-src/Language/Haskell/Lexer.hs.<br><br>Initial deadline: 1 Dec 2007.
<br><br><br>Thanks<br>Ian<br><br>_______________________________________________<br>Libraries mailing list<br><a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/libraries" target="_blank">
http://www.haskell.org/mailman/listinfo/libraries</a><br></blockquote></div><br>