Entry tags:
Haskell, newtype vs data
Сегодня на stackoverflow, отвечая на вопрос, Andreas Hammar привёл хорошие примеры. Сохраняю на будущее, как простые задачки для студентов
data D a = D a data S a = S !a newtype N a = N a constD x (D y) = x constS x (S y) = x constN x (N y) = xКакие из следующих вызовов завершат свою работу как Deep Thought, а какие как Earth?
D undefined `seq` 42 S undefined `seq` 42 N undefined `seq` 42 constD 42 undefined constS 42 undefined constN 42 undefined
no subject
no subject
no subject
no subject
no subject
no subject
Five minutes before the program was to finish running, Earth was destroyed by the Vogons, allegedly to make way for a hyperspace bypass but in fact to prevent the Ultimate Question being discovered, as it was seen as a threat to the psychiatric industry.
no subject
no subject
no subject