Add PrimMonad instances

Pointed out at: https://stackoverflow.com/q/52692508/369198
This commit is contained in:
Michael Snoyman 2018-10-08 08:18:57 +03:00
parent 1c2cb0c717
commit 55e0ca4bc3
No known key found for this signature in database
GPG Key ID: A048E8C057E86876
3 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,10 @@
# ChangeLog for yesod-core
## 1.6.9
* Add `PrimMonad` instances for `HandlerFor` and `WidgetFor` [from
StackOverflow](https://stackoverflow.com/q/52692508/369198)
## 1.6.8
* Sets the `X-XSS-Protection` header to `1; mode=block` [#1550](https://github.com/yesodweb/yesod/pull/1550)

View File

@ -17,6 +17,7 @@ import Control.Monad (ap)
import Control.Monad.IO.Class (MonadIO (liftIO))
import Control.Monad.Logger (LogLevel, LogSource,
MonadLogger (..))
import Control.Monad.Primitive (PrimMonad (..))
import Control.Monad.Trans.Resource (MonadResource (..), InternalState, runInternalState, MonadThrow (..), ResourceT)
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as L
@ -417,6 +418,10 @@ instance Monad (WidgetFor site) where
unWidgetFor (f a) wd
instance MonadIO (WidgetFor site) where
liftIO = WidgetFor . const
-- | @since 1.6.9
instance PrimMonad (WidgetFor site) where
type PrimState (WidgetFor site) = PrimState IO
primitive = liftIO . primitive
-- | @since 1.4.38
instance MonadUnliftIO (WidgetFor site) where
{-# INLINE askUnliftIO #-}
@ -448,6 +453,10 @@ instance Monad (HandlerFor site) where
HandlerFor x >>= f = HandlerFor $ \r -> x r >>= \x' -> unHandlerFor (f x') r
instance MonadIO (HandlerFor site) where
liftIO = HandlerFor . const
-- | @since 1.6.9
instance PrimMonad (HandlerFor site) where
type PrimState (HandlerFor site) = PrimState IO
primitive = liftIO . primitive
instance MonadReader (HandlerData site site) (HandlerFor site) where
ask = HandlerFor return
local f (HandlerFor g) = HandlerFor $ g . f

View File

@ -1,5 +1,5 @@
name: yesod-core
version: 1.6.8
version: 1.6.9
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>
@ -42,6 +42,7 @@ library
, mtl
, parsec >= 2 && < 3.2
, path-pieces >= 0.1.2 && < 0.3
, primitive >= 0.6
, random >= 1.0.0.2 && < 1.2
, resourcet >= 1.2
, rio