11

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.

  • 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). – Andres F. Jul 28 '17 at 0:32
  • 3
    @AndresF. It goes back at least to ML which Odersky was definitely very familiar with. – Derek Elkins Jul 28 '17 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. – Derek Elkins Jul 28 '17 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. – Derek Elkins Jul 28 '17 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. – Derek Elkins Jul 28 '17 at 3:23
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.