Question: contramap method doesn't make any sense to me

Question

contramap method doesn't make any sense to me

Answers 0
Added at 2017-01-01 21:01
Tags
Question

I am reading about the contramap method in Functors. What I understand about them is that if I have a type class F[B] (for example List[Int]) and I have a function which converts A => B (for example a method which converts String to Int) then I can get an F[A](for example List[String]).

But this seems illogical. How can you apply a function of type String => Int on a List[Int] and get a List[String]?

Maybe there is a typo in the literature which I am reading…

Please give me an example (preferably in scala) which explains contramap to me.

Answers
Source Show
◀ Wstecz