yellowtides / owenbot-hs

A utility bot written in Haskell for the Edinburgh Informatics Class of ‘24’s main messaging platform (Discord server).
https://yellowtid.es/owenbot-hs/
BSD 3-Clause "New" or "Revised" License
8 stars 7 forks source link

Remove polymorphism in DiscordMonad where not needed #44

Closed yutotakano closed 2 years ago

yutotakano commented 2 years ago

My original justification for the DiscordMonad polymorphism was to make it easier to test functions from IO or pure contexts. It has been proven in the year or so since its introduction that testing IO is simply quite difficult/painful/useless, and the extra polymorphism only adds to the complexity of the type signature of functions.

By removing the polymorphism from most functions, we can reason about the code with more convenience. We keep only the ones that strictly need to be polymorphic, like sendQuiz which needs to be called in scheduled IO as well as in DiscordHandler.

Some parts of the code may be reverted in the future if necessary, but that is good since it will explicitly signify that the polymorphism is required for those functions.