If I've got a function that returns IO Bool (specifically an atomically), is there any way to use the return value directly in the if statement, without binding?
So currently I've got
ok <- atomically $ do ... if (ok) then do ... else do ... Is it at all possible to write this as something like
if (*some_operator_here* atomically $ do ...) then do ... else do ... I was hoping there'd be a way to use something like <- anonymously, i.e., if (<- atomically ...) but so far no such luck.
Similarly on getLine, is it possible to write something like
if ((*operator* getLine) == "1234") then do ... Related addendum--what is the type of (<-)? I can't get it to show up in ghci. I'm assuming it's m a -> a, but then that would mean it could be used outside of a monad to escape that monad, which would be unsafe, right? Is (<-) not a function at all?
(<-)is not a function or expression and is built-in syntax that is part of "do" notation. It desugars to a call to(>>=)under the hood and you can read this to learn more about how that desugaring works.