
6 May
2022
6 May
'22
6:02 p.m.
Dear Cafe -
I wanted a quick example (for teaching) that shows a difference between data and newtype.
What examples do you use? I'm interested both in simple ones, and confusing/obfuscated ones.
Perhaps on the obscure side: I like to play with different implementations of Void. Let the students demonstrate that newtype Void = Void Void contains only one element whereas data Void = Void Void contains infinitely many elements that can be distinguished by pattern matching. Also consider data Void = Void !Void. Is this observably different from the Void newtype? Since you will have to explain lifting, you can also demonstrate that(,) is not the categorical product. Olaf