4 ms·
I don't see what let bindings have to do with solving the circular reference problem, those are just local bindings. A Haskell doubly-linked list would use IORe
by jeremyjh 3y ago
I don't see what let bindings have to do with solving the circular reference problem, those are just local bindings. A Haskell doubly-linked list would use IORef, but no one would ever actually do that.
- anon291 3y agoHaskell doubly linked list: data DLList a = DLList a (DLList a) (DLList a) | End make_dllist :: [a] -> DLList a make_dllist = go (\_ -> End) where go mkPrev [] = mkPrev End go mkPrev (x:xs) = go (\next -> let me = DLList x (mkPrev me) next in me) xs No need for IORef. Too many people misunderstand the meaning of 'let' in Haskell. It doesn't mean what you think it does. It defines, not assigns. In rust, let 'declares' and assigns in one go. It does not define.