[Haskell-cafe] Advice needed on how to improve some code

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Thu Apr 16 08:34:43 UTC 2015


On Thu, Apr 16, 2015 at 09:32:45AM +0100, Andrew Butterfield wrote:
> 
> > On 16 Apr 2015, at 09:22, Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> 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 \  

Not if the pl' doesn't exist because it became part of the body of an
abstracted function.  Anyway, I now suspect David Feuer was speaking about
use of >>= elsewhere in Jeff's code.


> >> On Wed, Apr 15, 2015 at 8:57 PM, Jeff <jeff at datalinktech.com.au> 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' ) >>=


More information about the Haskell-Cafe mailing list