Joachim Breitner schrieb:
Hi,
although semantically it could, ghc does not do common subexpression
elimination (CSE), at least not in every case. The canonical example
where it would be bad is the function (with div to avoid numerical
casting):
avg :: [Int] - Int
avg n = (sum [0..n]
Hello Henning,
Am Samstag, den 04.12.2010, 12:41 +0100 schrieb Henning Thielemann:
Joachim Breitner schrieb:
Now consider the program:
avg' :: [Int] - (Int, Int)
avg' n = (sum [0..n] `div` length [0..n], length [0..n])
It think this is not typecorrect, since 'n' denotes a list and
Joachim Breitner schrieb:
Am Samstag, den 04.12.2010, 12:41 +0100 schrieb Henning Thielemann:
Joachim Breitner schrieb:
Now consider the program:
avg' :: [Int] - (Int, Int)
avg' n = (sum [0..n] `div` length [0..n], length [0..n])
It think this is not typecorrect, since 'n' denotes a list
On Thu, Nov 25, 2010 at 2:32 AM, Joachim Breitner
m...@joachim-breitner.dewrote:
So I wonder:
* Is sharing values of type Int (and Bool and similar small values)
always safe?
* If so: does GHC already do that?
* Would it be technically possible?
* Is there an established theory that can
On Thu, Nov 25, 2010 at 11:32 AM, Joachim Breitner m...@joachim-breitner.de
wrote:
Hi,
although semantically it could, ghc does not do common subexpression
elimination (CSE), at least not in every case. The canonical example
where it would be bad is the function (with div to avoid numerical
Hi,
although semantically it could, ghc does not do common subexpression
elimination (CSE), at least not in every case. The canonical example
where it would be bad is the function (with div to avoid numerical
casting):
avg :: [Int] - Int
avg n = (sum [0..n] `div` length [0..n])
The reason why