Is there a way to make applicative uses of <$>
and <*>
look nice when dealing with infix operators? I think that
((++) <$> a <*> ((++) <$> b <*> c ))
looks much more cluttered then
a ++ b ++ c
so I wonder if there is a nicer way.
Is there a way to make applicative uses of <$>
and <*>
look nice when dealing with infix operators? I think that
((++) <$> a <*> ((++) <$> b <*> c ))
looks much more cluttered then
a ++ b ++ c
so I wonder if there is a nicer way.
(<++>) = liftA2 (++)
a <++> b <++> c
or
liftA2 (++) a $ liftA2 (++) b c
See Thomas Davie's InfixApplicative package, which provides a general syntactic trick, rather than having to define a new operator for each lifting.
a <^(++)^> (b <^(++)^> c)
--- can you confirm/deny? –
Mikaela SHE lets you write
(|a ++ (|b ++ c|)|)
if that's any use. Of course, there's some overhead to introducing a preprocessing layer.
© 2022 - 2024 — McMap. All rights reserved.
foldr1 (liftA2 (++)) [a, b, c]
. – Immunoreaction