typeclasses / haskell-phrasebook

The Haskell Phrasebook: a quick intro to Haskell via small annotated example programs
https://typeclasses.com/phrasebook
210 stars 22 forks source link

Add example for threadsafe logging. #40

Open friedbrice opened 4 years ago

friedbrice commented 4 years ago

Re: https://github.com/typeclasses/haskell-phrasebook/issues/14

friedbrice commented 4 years ago

Re: https://github.com/typeclasses/haskell-phrasebook/issues/15, too.

chris-martin commented 2 years ago

Finally getting back to this :sweat:

When run as an executable, not all the log messages get printed, because main doesn't join to the "sing" threads, so it quits before they finish. I'm considering using the async package instead of forkIO so we can have an easy facility to wait for thread termination.

friedbrice commented 2 years ago
  (log, print) <- do

I probably shouldn't be shadowing Prelude symbols, either 🙃

I'll play with this today and push what i end up with.

chris-martin commented 2 years ago

Hey, good to hear from you! Check out my PR, I've had some other thoughts as well.