4 ms·
> Since immutable values can't create cycles, no memory will be leaked. this is not generally true. in a lazy language, you can certainly say: main = mdo
by ferzul 6y ago
> Since immutable values can't create cycles, no memory will be leaked.
this is not generally true. in a lazy language, you can certainly say:
main = mdo
y <- f x
x <- g y
return y
the requirement is simply that you don't inspect the value of x until later (f makes something, y, to use later; when you use y, it inspects x). x and y now have references to each other.
- dependenttypes 6y ago> in a lazy language, you can certainly say: Not in haskell. Which language do you specifically have in mind?
- tome 6y agoYes indeed in Haskell. You have enable RecursiveDo for that particular example to work. I'm not sure why ferzul chose a recursive monadic computation when let { x = 0:y; y = 0:x } in x seems to demonstrate the same thing.