[Haskell-beginners] combine expressions in do block

Renah Scarowsky renahs at suite-sol.com
Wed Jan 8 08:09:18 UTC 2014


Is it possible to bind two expressions together within a case inside a do
block?

 

Given the following code running in the writer monad:

    f a = do
        case g a of
            Nothing -> return ()
            Just b ->
                h a (field1 b) (field2 b)
                
        case g a of
            Nothing -> return ()
            Just b ->
                i a (j a) (field1 b) (field2 b)



How can I combine these two cases together (or otherwise simplify the code)?

 

Thanks,

 

Renah Scarowsky

Suite Solutions

Create>Manage>Deploy

 <http://www.suite-sol.com/> http://www.suite-sol.com

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140108/e6605524/attachment.html>


More information about the Beginners mailing list