Hacker News new | ask | show | jobs
by chrisseaton 2288 days ago
> the madness of a function called `getchar` returning anything but a `char`

It’s effectively returning a Maybe(char).

1 comments

But it's not.

A `Maybe<char>` has exactly one `None` variant. While an `int` has many, many negative values.

Also, just calling it `None` (or similar) makes clear what is meant, while `-1` is some magic value.

> while `-1` is some magic value

It's a documented return value. Nothing magic about it.