# \[Solved\] Using \`whenJust\`

**URL:** <https://discourse.haskell.org/t/solved-using-whenjust/8761>\
**Category:** Learn\
**Created:** [February 8, 2024, 11:45pm UTC](https://discourse.haskell.org/t/solved-using-whenjust/8761 "2024-02-08T23:45:02Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![atravers](https://avatars.discourse-cdn.com/v4/letter/a/45deac/32.png) [@atravers](https://discourse.haskell.org/u/atravers)\
**Post date:** [February 9, 2024, 6:52am UTC](https://discourse.haskell.org/t/solved-using-whenjust/8761/5 "2024-02-09T06:52:53Z")

</div>

> [@mpilgrem](#):
>
> So:
> 
> ```haskell
> case mSomething of
> Nothing -> pure ()
> Just value -> do
> complicatedActionWith value
> 
> ```
> 
> can become:
> 
> ```haskell
> whenJust mSomething $ \value -> do
> complicatedActionWith value
> 
> ```

~~...or:

```haskell
do value <- whenJust mSomething pure
   complicatedActionWith value

```

 ~~
* * *

> [@mpilgrem](#):
>
> My question is: Is there any _downside_ with replacing the former form with the latter form?

As @tdammers noted [here](http://discourse.haskell.org/t/monadic-code-in-haskell/7872/23), it will depend on what the previous programmers (and now yourself) consider to be important: in some places using the `case`-expression could be more informative; in other places: not so much. But I would tend to leave alone those places where detailed _“walk-though”_ documentation exists - the writer of that documentation (and possibly the associated code) would have chosen that more verbose style for a reason…

---

_[View the full topic](https://discourse.haskell.org/t/solved-using-whenjust/8761)._
