15

Why is the Scala Option type not called Maybe, just as in Haskell?

Maybe makes a lot more "semantic sense" to me, but maybe Option has different behaviour I am not aware of.

Is there any particular reason why Option in Scala was not called Maybe?

gnat
  • 21,442
  • 29
  • 112
  • 288
fnl
  • 261
  • 2
  • 6

2 Answers2

24

Scala is also inspired by Ocaml, which uses Option.

Options are an Ocaml standard type that can be either None (undefined) or Some x where x can be any value. Options are widely used in Ocaml to represent undefined values (a little like NULL in C, but in a type and memory safe way)...

I think the name chosen is a matter of taste.

gnat
  • 21,442
  • 29
  • 112
  • 288
Mik378
  • 3,838
  • 7
  • 33
  • 60
  • 8
    F# too. The page on Wikipedia is http://en.wikipedia.org/wiki/Option_type. Seems to be a more standard name than `Maybe` – KChaloux Aug 09 '13 at 14:30
  • 3
    Ocaml gets the name from SML. In a quick glance through Landin's *The Next 700 Programming Languages* I didn't notice an option type, so SML might be the origin of the name. – Peter Taylor Aug 26 '13 at 10:56
  • 1
    An argument in favor of `Option` is that it's an `optional` value (either you get it or you don't). `Maybe` implies some degree of uncertainty on the programmer's part. _Maybe there is a value? I don't know.. Should I get a value?_ The wording `optional value` sounds more intentional in my opinion. – Jochem Kuijpers Aug 27 '19 at 15:20
7

A better question here would be why Haskell's option type is called Maybe. ML's option type is probably the grandaddy of all option types, and it's called option.

In any case, this is a terminological question, so it's not going to have a principled answer. The people who picked the name in Haskell liked it better, that's it.

sacundim
  • 4,748
  • 1
  • 19
  • 16
  • 2
    What possessed you to repeat information in a new answer that's already well-covered by the accepted answer and its underlying comments? – Robert Harvey Sep 15 '15 at 01:03
  • 6
    @RobertHarvey ML having set the precedent is new information, the real problem is that the answer is conjecturing even that. – djechlin Sep 15 '15 at 01:04
  • OK. Do you have a reference, or something more than just an opinion? Because opinions are better represented as comments, not answers. Especially your second paragraph. – Robert Harvey Sep 15 '15 at 01:09
  • 3
    **Def. Option:** The act of choosing; choice. **Def. Perhaps;** possibly; An uncertainity; An uncertain reply. For me that is eough to say Maybe is the much better name from a purely linguistic point of view. "Option" implies that there are (multiple) choices, while the monadic name "Maybe" is much more to the point: one thing or nothing. But yes, ML (and hence, Option) came first, so that may be the reason for the bad naming habbit (And see Peter Taylor's comment to the right answer above - he does reference ML). – fnl Sep 15 '15 at 12:25
  • @fnl See my comment on the other answer; I think there's a reasonable case to make that `option` is an abbreviation for `optional`. In which case the (multiple) choices are reduced to just two: either it's there or it isn't. – Jochem Kuijpers Aug 27 '19 at 15:25