aboutsummaryrefslogtreecommitdiffstats
path: root/src/Bot.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-08-27 00:40:55 +0200
committerTeddy Wing2017-08-27 00:40:55 +0200
commit8e5b862c9171af8af7c6c0d0456ae67a9e737633 (patch)
tree4c01da6c2381882eaecac3bb7a6139cf77b99931 /src/Bot.hs
parent46f05f8e4d87b2f9e09959bdfc0c890278568db2 (diff)
downloadsorbot-8e5b862c9171af8af7c6c0d0456ae67a9e737633.tar.bz2
privmsgFromPlugin: Rewrite using MaybeT monad transformer
OMG it works!!! This took me a week of off-and-on tinkering, learning, procrastinating, and struggling. So awesome that it's finally working! The `liftMaybe` was key, learned that from: https://stackoverflow.com/questions/8684252/how-to-inject-a-maybe-value-into-maybet This article on monad transformers by 'kqr' also helped quite a bit: https://github.com/kqr/gists/blob/master/articles/gentle-introduction-monad-transformers.md A Wikibooks article on the same was somewhat useful: https://en.wikibooks.org/wiki/Haskell/Monad_transformers And this was an interesting look at Alternatives, which I didn't end up using but was interesting nonetheless: http://www.parsonsmatt.org/2016/11/18/clean_alternatives_with_maybet.html When I learned about monad transformers I thought: "Yes! This is what I need to clean up the `privmsgFromPlugin` function.". I wasn't liking the nested `case` statements there, and since everything was a `Maybe`, I thought, why can't we chain the `Maybe`s like we're supposed to be able to with monads? Well, turns out we can. It just involved a lot of tricky `lift`ing. This gets rid of the nesting, resulting in a much cleaner- looking function. So cool!
Diffstat (limited to 'src/Bot.hs')
0 files changed, 0 insertions, 0 deletions