snapframework / snap

Top-level package for the official Snap Framework libraries, includes the snaplets API as well as infrastructure for sessions, auth, and templates.
http://snapframework.com/
BSD 3-Clause "New" or "Revised" License
455 stars 68 forks source link

Compiles with ghc 8.6.1 #206

Closed henrylaxen closed 5 years ago

henrylaxen commented 5 years ago

When I compile snap with ghc-8.6.1 I get:

src/Snap/Snaplet/HeistNoClass.hs:294:5: error: • No instance for (Control.Monad.Fail.MonadFail (Handler b (Heist b))) arising from a do statement with the failable pattern ‘(Running hs )’ • In a stmt of a 'do' block: (Running hs ) <- get In the expression: do (Running hs ) <- get withTop' id $ I.renderTemplate hs t >>= maybe pass serve In an equation for ‘iRenderHelper’: iRenderHelper c t = do (Running hs ) <- get withTop' id $ I.renderTemplate hs t >>= maybe pass serve where serve (b, mime) = do modifyResponse $ setContentType $ fromMaybe mime c .... | 294 | (Running hs _) <- get | ^^^^^^^^^^^^^^^^^^^^^^^^^

src/Snap/Snaplet/HeistNoClass.hs:308:5: error: • No instance for (Control.Monad.Fail.MonadFail (Handler b (Heist b))) arising from a do statement with the failable pattern ‘(Running hs )’ • In a stmt of a 'do' block: (Running hs ) <- get In the expression: do (Running hs ) <- get withTop' id $ maybe pass serve $ C.renderTemplate hs t In an equation for ‘cRenderHelper’: cRenderHelper c t = do (Running hs ) <- get withTop' id $ maybe pass serve $ C.renderTemplate hs t where serve (b, mime) = do modifyResponse $ setContentType $ fromMaybe mime c .... | 308 | (Running hs _) <- get | ^^^^^^^^^^^^^^^^^^^^^^^^^

This patch fixes it.

mightybyte commented 5 years ago

Rather than calling error I think a better solution is to provide a MonadFail instance. I just added it here:

https://github.com/snapframework/snap/commit/5ba5df1d14541044e9e23d145b853e672018640f

Can you give that a try and let me know if it fixes your problems?

henrylaxen commented 5 years ago

Hi Doug,

Seems to be fine. I got one warning when I compiled it which is fixed as follows:

diff --git a/src/Snap/Snaplet/Heist/Internal.hs b/src/Snap/Snaplet/Heist/Internal.hs index 5bbbbd2..c67ac63 100644 --- a/src/Snap/Snaplet/Heist/Internal.hs +++ b/src/Snap/Snaplet/Heist/Internal.hs @@ -9,7 +9,7 @@ import Data.Char import qualified Data.HashMap.Strict as Map import Data.IORef import Data.List -import Data.Monoid +import Data.Semigroup () import Data.Text (Text) import qualified Data.Text as T import Heist

Best wishes, Henry Laxen

Doug> Rather than calling error I think a better solution is to provide a
Doug> MonadFail instance. I just added it here:

Doug> 5ba5df1

Doug> Can you give that a try and let me know if it fixes your problems?

Doug> —
Doug> You are receiving this because you authored the thread.
Doug> Reply to this email directly, view it on GitHub, or mute the thread.*

-- Nadine and Henry Laxen The rest is silence Villa Alta #6
Calle Gaviota #10 Never try to teach a pig to sing Chapala It wastes your time
+52 (376) 765-3181 And it annoys the pig

mightybyte commented 5 years ago

Thanks for verifying this @henrylaxen. Unfortunately your warning fix doesn't compile on old versions of GHC. The warning is a pretty minor detail and I'm not going to worry about fixing it right now. If you want to fix it, open another PR for it so Travis will run and verify that the fix works on past GHC versions.