Sharing
From HaskellWiki
Sharing means that temporary data is physically stored, if it is used multiple times.
In
let x = sin 2 in x*x
x
x*x
Due to Referential transparency it does not play a role,
whethersin 2
whether it is computed once and the result is stored and reused.
However, when you writelet
This can be the wrong way, if a computation is cheap but its result is huge. Consider
[0..1000000] ++ [0..1000000]
where it is much cheaper to compute the list of numbers than to store it with full length.
Because the sharing property cannot be observed in Haskell, it is hard to transfer the sharing property to foreign programs when you use Haskell as an Embedded domain specific language. You must design a monad or use unsafePerformIO hacks, which should be avoided.
