Context:
do state1 <- act state
dispatch $! state1
What $! does ?
E.g. why it's not just dispatch state1 here?
Context:
do state1 <- act state
dispatch $! state1
What $! does ?
E.g. why it's not just dispatch state1 here?
$! is strict application, the difference from dispatch state1 is that state1 is guaranteed to be evaluated and not just kept as a lazy thunk. It's defined as
f $! x = x `seq` f x
Forcing evaluation in this way can be important for efficiency issues, such as preventing memory leaks.