From 05f4a6817bb9916ad45f7efb0738ed5b845b469e Mon Sep 17 00:00:00 2001 From: Jacques Comeaux Date: Sun, 16 Oct 2022 14:42:44 -0500 Subject: Update README --- .gitignore | 4 +++- README.md | 13 +++++++++++++ app/Main.hs | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c368d45..71a9191 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .stack-work/ -*~ \ No newline at end of file +tomatotbot.cabal +tomato.png +*~ diff --git a/README.md b/README.md index 16c61ea..6b08e1e 100644 --- a/README.md +++ b/README.md @@ -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 -- cgit v1.2.3