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.
1 Answer 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.
Explore related questions
See similar questions with these tags.
Maybeas a monad, they would likely usereturnand probably something likemzeroinstead ofNothing. WhenJustis used directly, usuallyMaybeisn't being used in monadic style at that point.Optiontype. The designers of Haskell probably felt thatfoo x = Just x"read" better thanfoo x = Some x. Similarly, the definitiondata Maybe a = Just a | Nothingreads pretty well as "Maybe ais eitherJust aor it'sNothing".Somereads reasonably well there, butNonedoesn't fordata Option a = Some a | None.