Replies: 4 comments
-
You can use forever :: Applicative f => f a -> f b For example: echo :: IO Void
echo = forever do
input <- getLine
putStrLn input |
Beta Was this translation helpful? Give feedback.
-
More generally, anything that won't terminate will be a computation of type |
Beta Was this translation helpful? Give feedback.
-
Yep, ditto to both of the previous comments. You could use |
Beta Was this translation helpful? Give feedback.
-
I think of it like this: A function's return type is a promise that you'll return that thing once you're done running. But if you never finish running, you never have to make good on that promise, so you can make wild claims. It's impossible to return |
Beta Was this translation helpful? Give feedback.
-
I'm sure I'm missing something obvious but for a thread that "never returns"
fork_
needs an IO Void.How do you make an IO Void? I mean I know it could be
undefined
which is of type a but that seems suboptimal!The only example I could find is in your test suite and you're using
throwIO
(which is also of type a, of course). Is that what you had in mind, that every daemon thread that "never returns" would end with athrow
?Beta Was this translation helpful? Give feedback.
All reactions