
27 Nov
2005
27 Nov
'05
4:55 p.m.
Arjan van IJzendoorn wrote: | > Is there a shorter way to write the if-then-else part below? | > if (cmdType cmd) /= (CmdSitError Server) | > then return $ Just seat_num | > else return Nothing | | return $ if cmdType cmd /= CmdSitError Serv | then Just seat_num else Nothing There's a subtle change in semantics when we move the 'if' inside the 'return'. The original code requires the condition to be evaluated as part of the do-expression's monad's structure, but the translated code defers it. 'return $! if ...' would be closer to the original. Regards, Tom
7114
Age (days ago)
7114
Last active (days ago)
0 comments
1 participants
participants (1)
-
tpledger@ihug.co.nz