From ab5b6b51718ab57a00b59125653aa52162179024 Mon Sep 17 00:00:00 2001 From: Tushar Adhatrao <40828350+tusharad@users.noreply.github.com> Date: Sat, 6 Apr 2024 02:14:22 +0530 Subject: [PATCH] Fixed Cookie example from Cookie module (#391) * Fixed Cookie example from Cookie module * modified changelog --- Web/Scotty/Cookie.hs | 4 ++-- changelog.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Web/Scotty/Cookie.hs b/Web/Scotty/Cookie.hs index b22af9e9..1474dc36 100644 --- a/Web/Scotty/Cookie.hs +++ b/Web/Scotty/Cookie.hs @@ -22,7 +22,7 @@ import Data.Monoid import Data.Maybe import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy.Read as TL (decimal) -import Web.Scotty (scotty, html) +import Web.Scotty (scotty, html, get) import Web.Scotty.Cookie (getCookie, setSimpleCookie) main :: IO () @@ -30,7 +30,7 @@ main = scotty 3000 $ get \"/\" $ do hits <- liftM (fromMaybe \"0\") $ 'getCookie' \"hits\" let hits' = - case TL.decimal hits of + case TL.decimal $ TL.fromStrict hits of Right n -> TL.pack . show . (+1) $ (fst n :: Integer) Left _ -> \"1\" 'setSimpleCookie' \"hits\" $ TL.toStrict hits' diff --git a/changelog.md b/changelog.md index a30badd3..1d1bfa6e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,5 @@ ## next [????.??.??] - +* Fixed cookie example from `Cookie` module documentation. `getCookie` Function would return strict variant of `Text`. Will convert it into lazy variant using `fromStrict`. ### Breaking changes * Remove dependency on data-default class (#386). We have been exporting constants for default config values since 0.20, and this dependency was simply unnecessary.