<html>
<head>
<meta name="generator" content="Windows Mail 17.5.9600.20689">
<style data-externalstyle="true"><!--
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
}
p.MsoNormal, li.MsoNormal, div.MsoNormal {
margin:0in;
margin-bottom:.0001pt;
}
p.MsoListParagraphCxSpFirst, li.MsoListParagraphCxSpFirst, div.MsoListParagraphCxSpFirst,
p.MsoListParagraphCxSpMiddle, li.MsoListParagraphCxSpMiddle, div.MsoListParagraphCxSpMiddle,
p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxSpLast {
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
line-height:115%;
}
--></style></head>
<body dir="ltr">
<div data-externalstyle="false" dir="ltr" style="font-family: 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif';font-size:12pt;"><div>Hello,</div><div><br></div><div>Given that you specifically indicated in your code that you wanted Int’s instance of Read and that the result of the product is way over 2 ^ 32 (or 2 ^ 64 for that matter), I’d guess the difference comes from the fact that the product of a is done with type Int (that is, modulo 32 or 64 depending on your computer’s CPU architecture) and the product with the litteral list is done with type Integer because that the type Haskell defaults to in this case.<br></div><div data-signatureblock="true"><div><br></div><div>ARJANEN Loïc Jean David<br>http://blog.luigiscorner.com<br>--- <br>“Computer science is no more about computers than astronomy is about telescopes, biology is about microscopes, or chemistry is about beakers and test tubes. Science is not about tools. It is about how we use them, and what we find out when we do.”<br>Michael R. Fellows and Ian Parberry</div><div><br></div></div><div style="padding-top: 5px; border-top-color: rgb(229, 229, 229); border-top-width: 1px; border-top-style: solid;"><div><font face=" 'Calibri', 'Segoe UI', 'Meiryo', 'Microsoft YaHei UI', 'Microsoft JhengHei UI', 'Malgun Gothic', 'sans-serif'" style='line-height: 15pt; letter-spacing: 0.02em; font-family: "Calibri", "Segoe UI", "Meiryo", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "sans-serif"; font-size: 12pt;'><b>De :</b> <a href="mailto:dot_wangyushi@yeah.net" target="_parent">m00nlight</a><br><b>Envoyé :</b> dimanche 8 mars 2015 21:59<br><b>À :</b> <a href="mailto:beginners@haskell.org" target="_parent">The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell</a></font></div></div><div><br></div><div dir=""><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"> <div>Hi Haskellers,<br><br>I encounter an strange behavior of haskell program recently. The following is my program<br><br>```haskell<br>main = do<br> _ <- getLine<br> arr1 <- getLine<br> _ <- getLine<br> arr2 <- getLine<br> let a = map (read :: String -> Int) (words arr1)<br> b = map (read :: String -> Int) (words arr2)<br><br> putStrLn $ show $ (foldl (*) 1 a)<br> putStrLn $ show $ a == [1,2,4,8,32,64,128,256,512,1024,2048,4906,8192]<br> putStrLn $ show $ (foldl (*) 1 [1,2,4,8,32,64,128,256,512,1024,2048,4906,8192])<br>```<br><br>With the input test file as following:<br><br>```test.in<br>13<br>1 2 4 8 32 64 128 256 512 1024 2048 4906 8192<br>9<br>1 3 9 27 81 243 729 2187 6561<br>```<br><br>The output is as:<br>```output<br>0<br>True<br>185343439719667835347140608<br>```<br><br>In fact, from the program, we know that a is equal to list [1,2,4,8,32,64,128,256,512,1024,2048,4906,8192] ,<br>but the product of a and the literal list is different.<br><br>Can anyone tell me why?<br><br>Thanks <br><br></div><div><br></div><div><br></div><div><br></div></div><div id="spnEditorSign"><div><div>--m00nlight<br></div></div></div><div><br></div><br><br><span><span id="netease_mail_footer"><span><span id="netease_mail_footer"></span></span>
</span></span></div></div>
</body>
</html>