I think this proposal goes the wrong way. 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> -- Lennart<br><br><div class="gmail_quote">
On Nov 17, 2007 2:02 PM, Ian Lynagh <<a href="mailto:igloo@earth.li">igloo@earth.li</a>> 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> <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'm formally proposing it now. It's trac #1902:<br> <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' is just around<br>the corner...).<br><br>In my opinion, (^) has the wrong type. Just as we have, for example,<br> (!!) :: [a] -> Int -> a
<br> genericIndex :: (Integral b) => [a] -> b -> a<br>we should also have<br> (^) :: (Num a) => a -> Int -> a<br> genericPower :: (Num a, Integral b) => a -> b -> a
<br>(or some other function name). The same goes for (^^) (genericPower').<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's easier to get
<br>-Wall clean without having to put :: Int annotations everywhere.<br><br>The impact to GHC'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>