# Why “Just” for Maybe?

**URL:** <https://discourse.elm-lang.org/t/why-just-for-maybe/2563>\
**Category:** Learn\
**Created:** [November 20, 2018, 1:46am UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563 "2018-11-20T01:46:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![CmTheLuke](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cmtheluke/32/1554_2.png) [@CmTheLuke](https://discourse.elm-lang.org/u/CmTheLuke)\
**Post date:** [November 20, 2018, 1:46am UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/1 "2018-11-20T01:46:23Z")

</div>

I assume that this was taken directly from Haskell, so maybe it’s really a question for that community, but “Just” seems like an odd choice. To me `Just a` suggests that there might be times when there is even more than the value of `a` associated with a valid value of the given Maybe. “Some” seems more correct to me. (Obviously not a huge deal)

---

<div class="post-metadata">

**Author:** ![Alexandre\_Bermand](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/alexandre_bermand/32/1415_2.png) [@Alexandre\_Bermand](https://discourse.elm-lang.org/u/Alexandre_Bermand)\
**Post date:** [November 20, 2018, 2:51am UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/2 "2018-11-20T02:51:42Z")

</div>

Hi,  
`Maybe = Nothing | Just a` is a common notation for a fundamental functional programming concept:

> **[Option type](https://en.wikipedia.org/wiki/Option_type)**
>
> In programming languages (more so functional programming languages) and type theory, an option type or maybe type is a polymorphic type that represents encapsulation of an optional value; e.g., it is used as the return type of functions which may or may not return a meaningful value when they are applied. It consists of a constructor which either is empty (named None or Nothing), or which encapsulates the original data type A (written Just A or Some A). Outside of functional programming, these a...

Haskell indeed uses that notation, so I would assume that this is where it came from in Elm.  
I personally prefer `Just a` to `Some a` for instance but it’s OK to feel differently 🙂

Hope this helps!

---

<div class="post-metadata">

**Author:** ![norpan](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/norpan/32/548_2.png) [@norpan](https://discourse.elm-lang.org/u/norpan)\
**Post date:** [November 20, 2018, 7:19am UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/3 "2018-11-20T07:19:40Z")

</div>

Naming things is one of the two hard problems of computer science 🙂

Another suggestion is `Have a`.

---

<div class="post-metadata">

**Author:** ![CmTheLuke](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cmtheluke/32/1554_2.png) [@CmTheLuke](https://discourse.elm-lang.org/u/CmTheLuke)\
**Post date:** [November 20, 2018, 12:43pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/4 "2018-11-20T12:43:52Z")

</div>

I wonder what people would think of

```
type Maybe a
= Yes a
| No
```

---

<div class="post-metadata">

**Author:** ![Atlewee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/atlewee/32/4603_2.png) [@Atlewee](https://discourse.elm-lang.org/u/Atlewee)\
**Post date:** [November 20, 2018, 1:02pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/5 "2018-11-20T13:02:20Z")

</div>

I find Nothing and Just to be the best nowdays, but in the beginning I was confused. I guess the simplest way for me to understand it when I was a beginner would be:

```auto
type Maybe a
= Value a
| NoValue

```

---

<div class="post-metadata">

**Author:** ![stevensonmt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/stevensonmt/32/889_2.png) [@stevensonmt](https://discourse.elm-lang.org/u/stevensonmt)\
**Post date:** [November 20, 2018, 3:12pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/6 "2018-11-20T15:12:16Z")

</div>

I didn’t really get it until after spending time on Rust where the type name `Option` made more sense than `Maybe` to me. That was more of a stumbling block than the `Just/Nothing` vs `Some/None` difference. I think because `Option` is a more concrete noun where `Maybe` is an adverb. (I do recognize that maybe gets used as a noun but that is less common and almost slang.)

---

<div class="post-metadata">

**Author:** ![CmTheLuke](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/cmtheluke/32/1554_2.png) [@CmTheLuke](https://discourse.elm-lang.org/u/CmTheLuke)\
**Post date:** [November 20, 2018, 3:55pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/7 "2018-11-20T15:55:33Z")

</div>

I’m fine with the concept (I’ve done a bit of F# so that made it easy). Some parts of the naming choices are subjective; I actually like “Maybe” better than F#’s “Option”. However, I think there’s a fairly objective case to be made that the word “Just” doesn’t really make sense in the context of a Maybe.

Perhaps I’m crazy.  
Just, nothing, maybe so. 😉

---

<div class="post-metadata">

**Author:** ![evancz](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/evancz/32/16_2.png) [@evancz](https://discourse.elm-lang.org/u/evancz)\
**Post date:** [November 20, 2018, 8:52pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/8 "2018-11-20T20:52:41Z")

</div>

I actually suggested `Yes` and `No` as alternate names in [this thread in 2013](https://groups.google.com/d/msg/elm-discuss/c5OqcUkpcxE/V6XrofQ3GhIJ). I agree with the root feeling here, but the cost to change felt pretty high even then. I like `Value` and `NoValue` as well. That is one of the ones I suggest when folks ask me about `Just` not making any sense.

I think the next step on this question would be to teach a bunch of people the concept using different names and see if you can observe anything different.

---

<div class="post-metadata">

**Author:** ![Qqwy](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/qqwy/32/1062_2.png) [@Qqwy](https://discourse.elm-lang.org/u/Qqwy)\
**Post date:** [November 21, 2018, 3:15pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/9 "2018-11-21T15:15:57Z")

</div>

For completeness sake, Rust uses `Option a : None | Some a`, and this is also the naming that Scala uses.

---

<div class="post-metadata">

**Author:** ![lassik](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@lassik](https://discourse.elm-lang.org/u/lassik)\
**Post date:** [November 21, 2018, 6:36pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/10 "2018-11-21T18:36:01Z")

</div>

OCaml also uses `Option`, `None` and `Some`.

IMHO `Maybe`, `Nothing` and `Just` are good choices because those words are relatively unambiguous. `Option` is a word can mean many things (optional arguments, command line options, configuration options, etc.) `Some` is sometimes the name of a function that says whether or not there exists a value in a collection satisfying the given test. `Yes` and `No` are sometimes used as alternative names for the boolean values `true` and `false` (e.g. in YAML).

It’s quite tricky to find words that are short, evocative and unambiguous.

---

<div class="post-metadata">

**Author:** ![HappMacDonald](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/happmacdonald/32/1069_2.png) [@HappMacDonald](https://discourse.elm-lang.org/u/HappMacDonald)\
**Post date:** [November 21, 2018, 11:51pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/11 "2018-11-21T23:51:14Z")

</div>

Well the Maybe package is simple enough that I wonder what cost there would be to just building alternate packages with identical functionality but different naming conventions, and then submitting those?

type YesNo = Yes a | No  
type MaybeValue = Value a | NoValue  
type Option = Some a | None

If one becomes popular enough in the community then perhaps it could challenge the incumbent core/default included convention. 🙂

---

<div class="post-metadata">

**Author:** ![eike](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/eike/32/749_2.png) [@eike](https://discourse.elm-lang.org/u/eike)\
**Post date:** [November 22, 2018, 11:16am UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/12 "2018-11-22T11:16:47Z")

</div>

It’s not that easy: Lot’s of functions in other packages return `Maybe`s, for example `List.head`. As long as those don’t provide alternatives, you would have to write wrappers yourself or live with a mixture of different `Maybe` types. In the latter case, you can’t use chaining with `Maybe.andThen` anymore unless the types happen to line up. I don’t think adoption would be high.

---

<div class="post-metadata">

**Author:** ![HappMacDonald](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/happmacdonald/32/1069_2.png) [@HappMacDonald](https://discourse.elm-lang.org/u/HappMacDonald)\
**Post date:** [November 22, 2018, 8:29pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/13 "2018-11-22T20:29:39Z")

</div>

Meh, we have elm-format, I wouldn’t be surprised if some other tool to root through your elm-stuff folder and search/replace terms would be that challenging either. Then every module using Maybe could use your preferred terminology instead. 😉

But yeah, I agree it does get to be a bit of a stretch. I just hate when networking effects lock us into decisions that may later (and after sufficient experience) prove to be sub-optimal. IIUC that’s the whole reason that Evan introduces new features into the language as slowly as he does: because those are genies you can’t put back into bottles.

---

<div class="post-metadata">

**Author:** ![eike](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/eike/32/749_2.png) [@eike](https://discourse.elm-lang.org/u/eike)\
**Post date:** [November 22, 2018, 8:53pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/14 "2018-11-22T20:53:58Z")

</div>

Sure, you can have a tool replace everything by your preferred terminology. But then there really is no need for a package: just do that locally and publish using `Maybe`. Explaining to newcomers that Elm has five different, incompatible ways of denoting basically the same thing and introducing them to a tool that makes those things work together seems worse than just having to explain that they are called `Just` and `Nothing` for historic reasons, even long term.

---

<div class="post-metadata">

**Author:** ![stevensonmt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/stevensonmt/32/889_2.png) [@stevensonmt](https://discourse.elm-lang.org/u/stevensonmt)\
**Post date:** [November 22, 2018, 9:53pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/15 "2018-11-22T21:53:08Z")

</div>

On further thought, what bothers me is the `Just`. I can’t really think of a context in which `Just` is the opposite of `None` or `Nothing`. It’s not a quantifying modifier. It typically is a modifier signalling a lesser importance. “That’s just my little brother.” “It’s just a flesh wound.”

In contrast, `Some` is a reasonable complement to `None`.

---

<div class="post-metadata">

**Author:** ![mdgriffith](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mdgriffith/32/61_2.png) [@mdgriffith](https://discourse.elm-lang.org/u/mdgriffith)\
**Post date:** [November 22, 2018, 11:07pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/16 "2018-11-22T23:07:28Z")

</div>

I agree `Just` feels a little weird. `Some` also implies some plurality like “O, I got some apples”.

`Only` might make more sense as it’s singular.

`type Maybe thing = Nothing | Only thing`

---

<div class="post-metadata">

**Author:** ![Atlewee](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/atlewee/32/4603_2.png) [@Atlewee](https://discourse.elm-lang.org/u/Atlewee)\
**Post date:** [November 22, 2018, 11:33pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/17 "2018-11-22T23:33:29Z")

</div>

There is also:

```auto
type Maybe a 
= Thing a
| NoThing

```

But “Thing 5”, “Some 5” and “Yes 5” all sounds strange compared to “Just 5”.  
I guess “Value 5” sounds ok.  
The problem with Value is that its already in use as rawJsValue.  
And keeping “Just” is actually not a problem when used to it. The cost of replacing it is much higher than gain in my opinion.  
Once you first understand the concept and that the maybe type is just a normal Custom type like any other, the names is not important.  
But for a beginner, I guess the Value a/NoValue would help self explain the concept.  
Edit:  
You could also keep the Nothing:

```auto
type Maybe a
= Value a 
| Nothing

```

---

<div class="post-metadata">

**Author:** ![stevensonmt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/stevensonmt/32/889_2.png) [@stevensonmt](https://discourse.elm-lang.org/u/stevensonmt)\
**Post date:** [November 23, 2018, 5:33am UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/18 "2018-11-23T05:33:53Z")

</div>

True about `Some` except when used for modifying collective nouns. While you would not say having one apple means you have some apples, you might say that you have some fruit. That makes it more sensible to me than `Just`.

---

<div class="post-metadata">

**Author:** ![Y0hy0h](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/y0hy0h/32/3579_2.png) [@Y0hy0h](https://discourse.elm-lang.org/u/Y0hy0h)\
**Post date:** [November 23, 2018, 7:16am UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/19 "2018-11-23T07:16:12Z")

</div>

I think, too, that `Just` is the confusing bit.

How about `Maybe a = Nothing | One a`?

---

<div class="post-metadata">

**Author:** ![matt.cheely](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/matt.cheely/32/4524_2.png) [@matt.cheely](https://discourse.elm-lang.org/u/matt.cheely)\
**Post date:** [November 23, 2018, 3:35pm UTC](https://discourse.elm-lang.org/t/why-just-for-maybe/2563/20 "2018-11-23T15:35:20Z")

</div>

I think @evancz is right in that trying out the ideas is the best way to vet them, but I have also been trying to think about exactly why terms like `Just` and `Some` feel awkward to people. After considering it for a while, I’ve managed to frame the problem in a way that makes sense to me and that hopefully will be of use to others, so I wanted to share it. It also led to another option I haven’t seen suggested before.

The short version is that I think the reason that `Just` and `Some` are confusing is that they carry additional meaning in normal usage that doesn’t apply in the context of the `Maybe` type.

`Just` implies an alternative to a different state, but usually one that is more interesting/surprising. Consider:

- I thought there might be a bear outside the tent, but when I looked it was just a rabbit.
- I thought there might be nothing outside the tent, but when I looked it was just a rabbit.

I’m not sure if the second of those is wrong, but I’ve never heard anyone speak like that. Additionally, “just” has [a lot of other meanings](https://www.dictionary.com/browse/just) that aren’t relevant in most contexts in a program.

`Some` has a similar problem with the additional wrinkle that the [meaning changes based on context and whether it’s used with a singular or plural noun](https://www.dictionary.com/browse/some):

- Some person may object
- Some people may object
- Some people were here

When used in the singular, “some” usually means an indefinite, unspecified, or arbitrary item. It can also mean that in the plural case, or it can mean a specific group based on some predicate. Each of those meanings is relevant in code sometimes, but not in every context, which can lead to confusion.

At the root of this issue is that both “some” and “just” are adjectives. They’re intended to modify the meaning of the noun they accompany, but the variant case of `Maybe` where the item is present doesn’t really modify the meaning of the item.

Because of all that, I think that `The` is a potential alternative to `Just`:

- It’s an article, not an adjective, so it doesn’t modify the meaning of the associated noun
- It works equally well with the singular and plural cases

p.s. I ran this idea past my wife to see how crazy it sounded, and she suggested `'Tis`😄

[Next page](https://discourse.elm-lang.org/t/why-just-for-maybe/2563.md?page=2)
