
On 16 Apr 2015, at 09:22, Tom Ellis
wrote: I rather like the >>= invocations. `do` notation would require naming intermediate variables.
But the >>= requires such intermediate variables anyway: all the pl' after the \
On Wed, Apr 15, 2015 at 8:57 PM, Jeff
wrote: return pl ) >>= ( \pl' -> let pld = P.payloadData pl' in if testBit mdm ( fromEnum D.GPS ) then parseDeviceGPSData >>= ( \s -> return ( pl' { P.payloadData = pld { P.gpsData = Just s } } ) ) else return pl' ) >>= ( \pl' -> let pld = P.payloadData pl' in if testBit mdm ( fromEnum D.GSM ) then parseDeviceGSMData >>= ( \s -> return ( pl' { P.payloadData = pld { P.gsmData = Just s } } ) ) else return pl' ) >>= ( \pl' -> let pld = P.payloadData pl' in if testBit mdm ( fromEnum D.COT ) then parseDeviceCOTData >>= ( \s -> return ( pl' { P.payloadData = pld { P.cotData = Just s } } ) ) else return pl' ) >>=
Do notation is just syntax sugar for the above do pl' <- ..... pl' <- .... pl' <- ... No additional variable invention required ! Andrew Butterfield School of Computer Science & Statistics Trinity College Dublin 2, Ireland