Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard prelude name for fmap . const

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!

like image 454
Tomer Avatar asked Dec 18 '22 14:12

Tomer


1 Answers

You are looking for (<$) :: Functor f => a -> f b -> f a.

like image 62
bradrn Avatar answered Jan 06 '23 07:01

bradrn