diff options
author | Jacques Comeaux <jacquesrcomeaux@gmail.com> | 2022-10-16 14:42:44 -0500 |
---|---|---|
committer | Jacques Comeaux <jacquesrcomeaux@gmail.com> | 2022-10-16 14:42:44 -0500 |
commit | 05f4a6817bb9916ad45f7efb0738ed5b845b469e (patch) | |
tree | 712a18ef8444359287e217e345502617e6042deb | |
parent | a2111ffa6e530e054c377d9538b8b066f218de29 (diff) |
Update README
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | app/Main.hs | 2 |
3 files changed, 17 insertions, 2 deletions
@@ -1,2 +1,4 @@ .stack-work/ -*~
\ No newline at end of file +tomatotbot.cabal +tomato.png +*~ @@ -1 +1,14 @@ # tomatobot + +My first Haskell web app: a GroupMe bot which could, hypothetically, be used to deliver on-demand random tomato images to a GroupMe chat, _but which should, of course, only be used when adapted to follow the terms of service of the [Unsplash API](https://unsplash.com/developers)_ + +Best practices meet a best-effort development cycle: +I wrote this in one day, following best practices when I knew about them and when it wasn't too much work. + +I structured the app with the [ReaderT design pattern](https://www.fpcomplete.com/blog/2017/06/readert-design-pattern/), and, as always, adhered to the tenets of [type-driven design](https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/). + +Things to do differently next time: + +- Use [Servant](https://docs.servant.dev/en/stable/) instead of WAI + Warp +- Don't commit hardcoded access tokens (they are no longer valid) +- Don't give up so early on error handling diff --git a/app/Main.hs b/app/Main.hs index f4fa1d0..0d5b8c3 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -32,7 +32,7 @@ runServer port = run port $ \request send -> do .| sinkParser Ae.json case Ae.fromJSON val of Ae.Success r -> return r - Ae.Error s -> throwM $ DecodeException $ "Recieve message: " <> T.pack s + Ae.Error s -> throwM $ DecodeException $ "Receive message: " <> T.pack s case eres of Left e -> send $ errorResponse e Right inMes -> do |