It's not a functor; "map" is bind. Here's an example in non-Haskell as I was addressing non-Haskell audience.
class Maybe {
value: int;
static wrap(v: int) {
return new Maybe { value = v }
}
// map() applies fn on the unwrapped value. fn returns a Maybe.
map(fn: (x: int) => Maybe) {
return this.value == null ? Maybe.wrap(null) : fn(this.value);
}
}
Here Maybe.wrap() is "unit" and Maybe.map() is "bind" in Haskell lingo. The whole thing is a monad. You can chain call with it.
Maybe.wrap(5)
.map(x => Maybe.wrap(x + 1))
.map(x => Maybe.wrap(x * 2))