From 23f286fce64b8cf44e17c8a5965486bc2f0033d7 Mon Sep 17 00:00:00 2001 From: tusharad Date: Wed, 27 Mar 2024 23:56:23 +0530 Subject: [PATCH 1/2] Fixed Cookie example from Cookie module --- Web/Scotty/Cookie.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 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' From 9b61bc2bd8c20e6a22a6b70ae11f344e6eaed307 Mon Sep 17 00:00:00 2001 From: tusharad Date: Wed, 3 Apr 2024 11:59:56 +0530 Subject: [PATCH 2/2] modified changelog --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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.