Why does laziness go well with referential transparency?

I read the Haskell tutorial (Learn You a Haskell), in which the author said that laziness goes well with link transparency. After more reading and searching, I still do not understand why. Please note that I really understand what sets us apart from referential transparency and laziness, but they are together that bother me.

Is there any particular advantage to combining the two?

Or maybe the author just wanted to say that they are both good to have and express this ambiguously?

+5
source share
3 answers

. (, ) , . -, , , , . Java:

long start = System.currentTimeMillis(); //get the start time
runBenchmarkFunction();
System.out.println("Run took " + (System.currentTimeMillis() - start) + " ms"); 

, . , 0 ( ). , , . , System.currentTimeMillis . , " ", sin ln, .

+11

, . , , . - , - , .

, .

+5

Python, . - , , , , - .

foo = 0

def foo_sequence():
    global foo
    while True:
        foo += 1
        yield foo

>>> generator = foo_sequence()
>>> generator.next()
1
>>> generator.next()
2
>>> foo = 5
>>> generator.next()
6

, . , ( ) .

+4
source

All Articles