haskell - Removing duplication (with Applicative ((->) t), perhaps?) -
i playing around simple function else's stack overflow question, , wrote expression:
f x ++ f y obviously best way write expression in real life, given have variables in scope anyway, saw duplication of f a, , thought "hey, maybe can remove applicative instance functions". wound with:
lifta2 (++) (flip f x) (flip f y) which awful. there nicer way remove duplication?obviously remove duplication binding f a in where clause, intended exercise in using built-in functions.
you do
((++) `on` f a) x y that doesn't use applicative, though (sorry).
Comments
Post a Comment