
Perhaps, if the students have been in contact with a language that has explicit pointers (C or C++), let them implement linked lists and concatenation in that procedural language. (An AI will likely also produce a correct implementation nowadays.) The advantage is that one can inspect the values of the pointers to see whether any copying has happened. Then the students easily see that only the spine (structure holding pointers) is re-created, but the memory the list elements point to is never touched. That is an instance of parametricity, I believe. The fact that length (replicate 3 undefined ++ replicate 2 undefined) evaluates to 5 also shows this. Olaf

Or you can use ghc-vis: https://dennis.felsing.org/ghc-vis/ https://www.youtube.com/watch?v=I4lnCG18TaY Jaro On 13-07-2023 16:44, Olaf Klinke wrote:
Perhaps, if the students have been in contact with a language that has explicit pointers (C or C++), let them implement linked lists and concatenation in that procedural language. (An AI will likely also produce a correct implementation nowadays.) The advantage is that one can inspect the values of the pointers to see whether any copying has happened. Then the students easily see that only the spine (structure holding pointers) is re-created, but the memory the list elements point to is never touched. That is an instance of parametricity, I believe. The fact that
length (replicate 3 undefined ++ replicate 2 undefined)
evaluates to 5 also shows this.
Olaf
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
participants (2)
-
Jaro Reinders
-
Olaf Klinke