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.
Maybe
as a monad, they would likely usereturn
and probably something likemzero
instead ofNothing
. WhenJust
is used directly, usuallyMaybe
isn't being used in monadic style at that point.Option
type. The designers of Haskell probably felt thatfoo x = Just x
"read" better thanfoo x = Some x
. Similarly, the definitiondata Maybe a = Just a | Nothing
reads pretty well as "Maybe a
is eitherJust a
or it'sNothing
".Some
reads reasonably well there, butNone
doesn't fordata Option a = Some a | None
.