Jakob Brünker wrote a #Haskell GHC plugin to allow monadic values within expressions, if prefixed with a bang:

help :: Reader Contact String
help = do
pure $
"Call us at " <> (!ask).phone <> " or email " <> (!ask).email

Very exiting experiment!
hackage.haskell.org/package/mo

Follow

@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 discourse.haskell.org/t/monadi)

@nomeata I know... It just rubs me wrong way that a line marked by "pure" becomes a source of effects.

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.