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

As Martin points out in his response, the Scala version of map isn't restricted to returning a list so (a -> b) -> [a] -> [b] isn't directly comparable. To make a similar version in Haskell you'd have to use a language extension (MultiParamTypeClasses?) and the type signature would be significantly more complex.

It's debatable whether the complexity of the API is worth the additional functionality, but the basic version of map (Data.List.map :: (a -> b) -> [a] -> [b]) is utterly trivial in either language.



> To make a similar version in Haskell you'd have to use a language extension (MultiParamTypeClasses?) and the type signature would be significantly more complex.

Eh? No language extensions necessary.

    fmap :: Functor f => (a -> b) -> f a -> f b
Perhaps I'm missing something though...


That can only be used with a fixed functor f; the scala version can send an (a -> b) to a (f a -> that), for any [a, b, that] combination for which a CanBuildFrom is available (this is basically a more generalized typeclass).




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: