Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Are you hinting at Haskell's fmap? The type signature is significantly simpler:

fmap :: Functor f => (a -> b) -> f a -> f b



That doesn't capture the type of the original example.

    BitSet(1, 2, 3).map { _.toString + "!" } // returns Set[String]
The Scala code here starts with one Functor (BitSet) and returns a different Functor (Set), depending on the type of the function (in this case, Int => String). If the function had type (Int => Int), it would still return a BitSet.

The signature for fmap does not encode this flexibility.


Thanks for explaining. I now understand what the OP meant by "automatic conversions".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: