12

The intuition of an optional type like Maybe Int is that either there is no Int (thus, there's Nothing there) or that there is some Int; there is something there.

It makes sense to me that we call the type constructor for the "negative" case Nothing, since it means exactly that -- that there's no Int there. But why use the word Just in the case where the emphasis is on something actually being there?

To me, the word "Just" carries the connotation that the thing it's describing is less than the alternative; the opposite of something actually being there; for example,

A: Are you doing anything tonight?

B: No; I'm just gonna stay in and watch TV.

A: Did you investigate the creepy ghost sounds around your house?

B: yeah, turns out it was actually just an owl.

Clearly I'm lacking whatever intuition this naming choice was based on. What is it? Because to me, the word Just means the opposite of how it's used in the Maybe type.

asked Jul 27, 2017 at 23:32
17
  • 4
    In this case, I think the Scala went with the better name of Some as opposed to None (not saying it's Scala's invention). Commented Jul 28, 2017 at 0:32
  • 3
    @AndresF. It goes back at least to ML which Odersky was definitely very familiar with. Commented Jul 28, 2017 at 3:17
  • 2
    @RobertHarvey If a Haskeller was using Maybe as a monad, they would likely use return and probably something like mzero instead of Nothing. When Just is used directly, usually Maybe isn't being used in monadic style at that point. Commented Jul 28, 2017 at 3:20
  • 2
    The historical precedent would have been the Option type. The designers of Haskell probably felt that foo x = Just x "read" better than foo x = Some x. Similarly, the definition data Maybe a = Just a | Nothing reads pretty well as "Maybe a is either Just a or it's Nothing". Some reads reasonably well there, but None doesn't for data Option a = Some a | None. Commented Jul 28, 2017 at 3:22
  • 3
    They are still alive. You can email people like Phil Wadler and Simon Peyton Jones and ask them. Or try the Haskell-Cafe mailing list. Commented Jul 28, 2017 at 3:23

1 Answer 1

1

This has been explained in the past by Simon Peyton Jones. It implies that either Nothing can be the value or 'just' a single other type value. There is 'just' one other thing that can be returned as a value, or nothing.

answered Sep 19, 2017 at 9:38

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.