Hardy Jones
1 min readJan 7, 2016

--

You string example from this post is also not a `Functor`: https://medium.com/@dtinth/what-is-a-functor-dcf510b098b6#.oqyyabc6s You’ve made the implementation work with exactly one type: `String`. But to be a `Functor`, the data type must be polymorphic. As the data type creator, you do not get to choose the underlying type that `map` operates on. If you choose this, then the data type is no longer a `Functor`, it is a data type with a `map` function.

To put this into some perspective: `Text` is a pretty good approximation to what `String` is in js: http://hackage.haskell.org/package/text-1.2.2.0/docs/Data-Text.html. Notice that you can `map`: http://hackage.haskell.org/package/text-1.2.2.0/docs/Data-Text.html#v:map over the `Char`s within a `Text`, but also notice that `Text` is not a `Functor`. It cannot be a `Functor` because `Text` is not polymorphic.

`String` in js is similar. Since it is not polymorphic, you cannot create a `Functor` implementation for it. You can create a `map` function, that does operate over each character code as you did in your post. But just having a `map` function does not make a data type a `Functor`, as you pointed out above.

--

--