Application Style
(++)<$>Just "a"<*>Just "b" --=Just "ab"
This is often the case, such as
(++)<$>Just "a"<*>Just "b"<*>Just "c"<*>...--Just "abc...
Would it be possible to write it down so that it can be connected to ?
haskell
(++)<$>Just "a"<*>Just "b" --=Just "ab"
So, the reason why only two Maybe Strings can be connected is because the original (++)
can only take two arguments.To put it another way, the above formula is (++) "a" "b"
as the Maybe application.
(++)
Since you can't take any number of strings by yourself, think of a way to concatenate any number of strings with a prime string before making it applicable.
foldl1(++)["a", "b", "c"] --="abc"
Also, make the string and function applicable.
foldl1(liftA2(++))[Just "a", Just "b", Just "c"] --= Just "abc"
fold1(liftA2(++)) [Just "a", Nothing, Just "c" ] -- = Nothing
© 2024 OneMinuteCode. All rights reserved.