A Tour of Go in Haskell

GitHub Language
Default Selection

The select in Go can include a default case when there is no other available communication. A default case makes select non-blocking.

In our Haskell-version select, we can simply add an operation to the end of our list which never blocks.

select [ readTQueue c >>= (\i -> return $ do
           -- use i
           )
       , return $ do
           -- if `readTQueue c` block
       ]

The sample code on the right side also implements functions similar to time.Tick and time.After from Go.

< 6 / 11 >