[Haskell-cafe] do vs. pattern matching

2012-08-04 Thread Matthew
I'm a somewhat experienced coder but I am relatively new to Haskell. I've got a question about whether a usage of do notation is idiomatic, or whether it's better to use pattern matching. I've got two functions which take an input and return Maybe SomeType. If either returns Nothing, I also want

Re: [Haskell-cafe] do vs. pattern matching

2012-08-04 Thread Benjamin Edwards
The do notation in this instance yields a nice advantage: if you want to switch to a different monad to encapsulate failure you will meely need to swap out the type signature and your function will need no further work. On Aug 4, 2012 7:35 AM, Matthew wonderzom...@gmail.com wrote: I'm a somewhat

Re: [Haskell-cafe] do vs. pattern matching

2012-08-04 Thread Johan Holmquist
Also if you don't need foo and bar you can write: callFoo callBar return baz //Johan On Aug 4, 2012 8:36 AM, Matthew wonderzom...@gmail.com wrote: I'm a somewhat experienced coder but I am relatively new to Haskell. I've got a question about whether a usage of do notation is idiomatic, or

Re: [Haskell-cafe] do vs. pattern matching

2012-08-04 Thread Alexander Solla
On Fri, Aug 3, 2012 at 11:34 PM, Matthew wonderzom...@gmail.com wrote: I'm a somewhat experienced coder but I am relatively new to Haskell. I've got a question about whether a usage of do notation is idiomatic, or whether it's better to use pattern matching. I've got two functions which take

Re: [Haskell-cafe] do vs. pattern matching

2012-08-04 Thread Matthew
On Sat, Aug 4, 2012 at 7:05 AM, Alexander Solla alex.so...@gmail.com wrote: On Fri, Aug 3, 2012 at 11:34 PM, Matthew wonderzom...@gmail.com wrote: I'm a somewhat experienced coder but I am relatively new to Haskell. I've got a question about whether a usage of do notation is idiomatic, or

Re: [Haskell-cafe] do vs. pattern matching

2012-08-04 Thread Donn Cave
On Sat, Aug 4, 2012 at 7:05 AM, Alexander Solla alex.so...@gmail.com wrote: On Fri, Aug 3, 2012 at 11:34 PM, Matthew wonderzom...@gmail.com wrote: ... With do notation, I can write something like this: do foo - callFoo x bar - callBar x return (baz)