# Staying sane with Maybe (maybe vs type)

**URL:** <https://discourse.elm-lang.org/t/staying-sane-with-maybe-maybe-vs-type/9897>\
**Category:** Learn\
**Created:** [July 23, 2024, 9:16pm UTC](https://discourse.elm-lang.org/t/staying-sane-with-maybe-maybe-vs-type/9897 "2024-07-23T21:16:46Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Sebastian](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/sebastian/32/98_2.png) [@Sebastian](https://discourse.elm-lang.org/u/Sebastian)\
**Post date:** [July 26, 2024, 1:14am UTC](https://discourse.elm-lang.org/t/staying-sane-with-maybe-maybe-vs-type/9897/11 "2024-07-26T01:14:59Z")

</div>

> [@badlydrawnrob](#):
>
> - Or default data in your `json` (instead of a `Maybe`)?

I think you should prefer a Maybe, rather than default data. As default data just hides potential issues and mute errors. I think you should make it obvious that you are missing something, and push it until the very end to deal with that e.g. show an empty view.

> [@badlydrawnrob](#):
>
> - But `Maybe` types are fine to use, as is `Maybe.withDefault`.

Maybes are fine. Your own descriptive custom type is better.  
I recommend not reaching for `withDefault` early. Try to use `Maybe.withDefault` at the very end, e.g. in the view that needs to show something.

---

_[View the full topic](https://discourse.elm-lang.org/t/staying-sane-with-maybe-maybe-vs-type/9897)._
