2 ms·
From the "defining functions" example (https://typeclasses.com/phrasebook/defining-functions https://typeclasses.com/phrasebook/defining-functions): greetNex
by tremon 5y ago
From the "defining functions" example (https://typeclasses.com/phrasebook/defining-functions https://typeclasses.com/phrasebook/defining-functions):
greetNext x = (next x, greet (show (next x)))
Is this actually valid, unambiguous code? What determines which `next x` gets evaluated first?
(edit: oh, nvm, x isn't a state, so both `next x` evaluate to the same value)
- fn-mote 5y ago> x isn't a state, so both `next x` evaluate to the same value Yes. More generally, Haskell functions are pure (side-effect free), so you always expect the same input value to result in the same output.
- rout39574 5y agoAnd they first explain "show" in the following passage. I wish they had run more novices through these phrases.