coding style - Haskell similar types copy-paste elimination in case -


case x of    cond expr stmt ->         checkexprtype expr bool         processstmt env stmt         return env   anothercond expr stmt ->         checkexprtype expr bool         processstmt env stmt         return env 

how can copy-paste eliminated?

you make local definition function of expr , stmt:

-- assume inside 'do' block let conditionallike expr stmt =         checkexprtype expr bool         processstmt env stmt         return env case x of     cond expr stmt -> conditionallike expr stmt     anothercond expr stmt -> conditionallike expr stmt 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

c++ - How to test/verify that zero-initialization takes place -

node.js - Webpack/TypeScript Raising Errors When node_modules is Excluded -