await x + y
(+) <$> getx <*> gety
* summing two reads in a Transaction,
* summing two parsed numbers in a Parser,
* summing two Nullable values into one Nullable value,
* producing a Validated<T> by validating two of its parts which require validation,
* and on and on.
It's even the cartesian product when run on lists:
let suits = ["♠", "♥", "♦", "♣"] let nums = concat [["A"], map show [2..10], ["J","Q","K"]] let cards = (++) <$> nums <*> suits putStrLn (unwords (take 15 cards)) A♠ A♥ A♦ A♣ 2♠ 2♥ 2♦ 2♣ 3♠ 3♥ 3♦ 3♣ 4♠ 4♥ 4♦
Also, it looks like you can just do it with ! in Haskell: https://hackage.haskell.org/package/monadic-bang
Yes, although it's slightly clumsy.
example = do let suits = ["♠", "♥", "♦", "♣"] let nums = concat [["A"], map show [2..10], ["J","Q","K"]] let cards = do pure (!nums ++ !suits) putStrLn (unwords (take 15 cards)) ghci> example A♠ A♥ A♦ A♣ 2♠ 2♥ 2♦ 2♣ 3♠ 3♥ 3♦ 3♣ 4♠ 4♥ 4♦
* summing two reads in a Transaction,
* summing two parsed numbers in a Parser,
* summing two Nullable values into one Nullable value,
* producing a Validated<T> by validating two of its parts which require validation,
* and on and on.
It's even the cartesian product when run on lists:
Swift, Roc, Rust and JS have specialised their syntax for just one of these concerns.Also, it looks like you can just do it with ! in Haskell: https://hackage.haskell.org/package/monadic-bang