
Olaf, This brings up something that's been niggling me for a while. Why can Hat not deal with defaulting? Surely it could be handled by the first stage of hat-trans being inserting explicit type signatures based on the standard defaulting rules? Bob On 17 Nov 2006, at 20:43, Olaf Chitil wrote:
This is caused by a limitation of Hat: Hat cannot handle defaulting of numeric classes.
Your Haskell program makes use of defaulting: The main function could work with numbers of either type Int or Integer. The Haskell defaulting rule says that in such a case it should choose Integer.
To help Hat add a type annotation, e.g.
main = do { print (takeodds [(1::Integer) ..7]); }
To get a better error message, you could compile your original program without -hat but with the additonal line
default()
which turns defaulting off and thus will yield an error message about an ambiguous type variable referring to your original program.
In real programs we have hardly ever come across uses of defaulting.
Ciao, Olaf
Aditya Siram wrote:
The following program compiles and runs on GHC 6.6 but fails to compile with the '-hat' option to hmake. The error message is: **Begin Output** hat-trans HatTest.hs Wrote Hat/HatTest.hs ghc-6.6 -c -package hat -o Hat/HatTest.o Hat/HatTest.hs
Hat/HatTest.hs:40:50: Ambiguous type variable `a' in the constraint: `Integral a' arising from use of `htakeodds' at Hat/HatTest.hs:40:50-58 Probable fix: add a type signature that fixes these type variable(s) **End Output**
The program source is:
import Prelude
takeodds xs = [ x | x <- xs, (mod x 2) ==0]
main = do { print (takeodds [1 ..7]); }
Thanks... Deech
_________________________________________________________________ Talk now to your Hotmail contacts with Windows Live Messenger. http://clk.atdmt.com/MSN/go/msnnkwme0020000001msn/direct/01/? href=http://get.live.com/messenger/overview
_______________________________________________ Hat mailing list Hat@haskell.org http://www.haskell.org/mailman/listinfo/hat
_______________________________________________ Hat mailing list Hat@haskell.org http://www.haskell.org/mailman/listinfo/hat