Replies: 4 comments
-
|
You can use forever :: Applicative f => f a -> f bFor 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.
Uh oh!
There was an error while loading. Please reload this page.
-
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
undefinedwhich 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