The composition fmap . const
is a function that takes some constant and a set of elements and returns a set of elements in which all the elements in set are replaced with the constant.
For example, (fmap . const) 5 [1,2,7]
returns [5,5,5]
.
Is there any standard prelude function that does exactly that?
Thanks!
You are looking for (<$) :: Functor f => a -> f b -> f a
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With