I’ve just found Const in the documentation of Control.Applicative, but I have a hard time working out where this is useful, over just using Monoid directly.
What am I missing?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s rather useful when combined with
Traversable.That’s the general recipe for glomming a bunch of stuff together. It was one of the use cases which convinced me that it was worth separating
ApplicativefromMonad. I needed stuff like generalizedelemto do occur-checking for a
Traversable Termparametrized by the representation of free variables. I kept changing the representation ofTermand I was fed up modifying a zillion traversal functions, some of which were doing accumulations, rather than effectful mapping. I was glad to find an abstraction which covered both.