Jakob Brünker wrote a #Haskell GHC plugin to allow monadic values within expressions, if prefixed with a bang:
help :: Reader Contact Stringhelp = do pure $ "Call us at " <> (!ask).phone <> " or email " <> (!ask).email
Very exiting experiment!https://hackage.haskell.org/package/monadic-bang-0.1.0.0
@nomeata Don't like how it makes `pure` a lie.
Would be nicer to readers if it would apply its magic only when wrapped in a something like `apply $ "call us at" <> (!ask)
@dpwiz The `pure` here isn’t special, though, but just a normal monadic, and the banged expressions can be anywhere within a `do` block:
putStrLn $ "The current value is " <> show !(readIORef counter)
(There is also a thread at https://discourse.haskell.org/t/monadic-bang-a-plugin-for-more-concise-do-block-notation-inspired-by-idris/5556?u=nomeata)
@nomeata I know... It just rubs me wrong way that a line marked by "pure" becomes a source of effects.
QOTO: Question Others to Teach Ourselves An inclusive, Academic Freedom, instance All cultures welcome. Hate speech and harassment strictly forbidden.
@dpwiz The `pure` here isn’t special, though, but just a normal monadic, and the banged expressions can be anywhere within a `do` block:
putStrLn $ "The current value is " <> show !(readIORef counter)
(There is also a thread at https://discourse.haskell.org/t/monadic-bang-a-plugin-for-more-concise-do-block-notation-inspired-by-idris/5556?u=nomeata)