[Haskell-beginners] Hints on how to remove unsafePerformIO from my function?

Brent Yorgey byorgey at seas.upenn.edu
Mon Jul 19 12:20:34 EDT 2010


On Mon, Jul 19, 2010 at 11:18:28AM -0400, David McBride wrote:
> Okay, I figured this out on my own.  This isn't as elegant but it definitely
> works:
> 

By the way, your code can be simplified using forever; these ought to
be equivalent:

> fetchUDPSIP :: TChan a -> TChan B.ByteString -> IO ()
> fetchUDPSIP commands chan = do
>   sock <- getUDPSocket 5060
>   forever $ do
>     result <- getUDP sock
>     (atomically . writeTChan chan) result
> 
> fetchLine = forever $ do
>   result <- Prelude.getLine
>   Prelude.putStrLn result

-Brent


More information about the Beginners mailing list