monad-peel

This commit is contained in:
Michael Snoyman 2010-12-16 17:47:13 +02:00
parent 05fde1f464
commit 29c0fb7a2b
4 changed files with 11 additions and 29 deletions

View File

@ -13,7 +13,7 @@ module Yesod
, Application , Application
, lift , lift
, liftIO , liftIO
, MonadInvertIO , MonadPeelIO
, mempty , mempty
, showIntegral , showIntegral
, readIntegral , readIntegral
@ -41,7 +41,7 @@ import Yesod.Hamlet
import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Class (lift)
import Control.Monad.IO.Class (liftIO) import Control.Monad.IO.Class (liftIO)
import Data.Monoid (mempty) import Data.Monoid (mempty)
import Control.Monad.Invert (MonadInvertIO) import Control.Monad.IO.Peel (MonadPeelIO)
showIntegral :: Integral a => a -> String showIntegral :: Integral a => a -> String
showIntegral x = show (fromIntegral x :: Integer) showIntegral x = show (fromIntegral x :: Integer)

View File

@ -112,8 +112,7 @@ import Control.Failure (Failure (failure))
import Text.Hamlet import Text.Hamlet
import Control.Monad.Invert (MonadInvertIO (..)) import Control.Monad.IO.Peel (MonadPeelIO)
import Control.Monad (liftM)
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified Data.ByteString.Char8 as S8 import qualified Data.ByteString.Char8 as S8
@ -210,7 +209,7 @@ newtype GHandler sub master a =
GHandler GHandler
{ unGHandler :: GHInner sub master a { unGHandler :: GHInner sub master a
} }
deriving (Functor, Applicative, Monad, MonadIO) deriving (Functor, Applicative, Monad, MonadIO, MonadPeelIO)
type GHInner s m = type GHInner s m =
ReaderT (HandlerData s m) ( ReaderT (HandlerData s m) (
@ -222,15 +221,6 @@ type GHInner s m =
type SessionMap = Map.Map String String type SessionMap = Map.Map String String
instance MonadInvertIO (GHandler s m) where
newtype InvertedIO (GHandler s m) a =
InvGHandlerIO
{ runInvGHandlerIO :: InvertedIO (GHInner s m) a
}
type InvertedArg (GHandler s m) = (HandlerData s m, (SessionMap, ()))
invertIO = liftM (fmap InvGHandlerIO) . invertIO . unGHandler
revertIO f = GHandler $ revertIO $ liftM runInvGHandlerIO . f
type Endo a = a -> a type Endo a = a -> a
-- | An extension of the basic WAI 'W.Application' datatype to provide extra -- | An extension of the basic WAI 'W.Application' datatype to provide extra

View File

@ -46,7 +46,7 @@ import Control.Monad.IO.Class (MonadIO)
import Control.Monad.Trans.Class (lift) import Control.Monad.Trans.Class (lift)
import Yesod.Internal import Yesod.Internal
import Control.Monad.Invert (MonadInvertIO (..)) import Control.Monad.IO.Peel (MonadPeelIO)
import Control.Monad (liftM) import Control.Monad (liftM)
import qualified Data.Map as Map import qualified Data.Map as Map
@ -54,7 +54,7 @@ import qualified Data.Map as Map
-- site datatypes. This is basically a large 'WriterT' stack keeping track of -- site datatypes. This is basically a large 'WriterT' stack keeping track of
-- dependencies along with a 'StateT' to track unique identifiers. -- dependencies along with a 'StateT' to track unique identifiers.
newtype GWidget s m a = GWidget { unGWidget :: GWInner s m a } newtype GWidget s m a = GWidget { unGWidget :: GWInner s m a }
deriving (Functor, Applicative, Monad, MonadIO) deriving (Functor, Applicative, Monad, MonadIO, MonadPeelIO)
type GWInner sub master = type GWInner sub master =
WriterT (Body (Route master)) ( WriterT (Body (Route master)) (
WriterT (Last Title) ( WriterT (Last Title) (
@ -69,15 +69,6 @@ type GWInner sub master =
instance Monoid (GWidget sub master ()) where instance Monoid (GWidget sub master ()) where
mempty = return () mempty = return ()
mappend x y = x >> y mappend x y = x >> y
instance MonadInvertIO (GWidget s m) where
newtype InvertedIO (GWidget s m) a =
InvGWidgetIO
{ runInvGWidgetIO :: InvertedIO (GWInner s m) a
}
type InvertedArg (GWidget s m) =
(Int, (HandlerData s m, (Map.Map String String, ())))
invertIO = liftM (fmap InvGWidgetIO) . invertIO . unGWidget
revertIO f = GWidget $ revertIO $ liftM runInvGWidgetIO . f
instance HamletValue (GWidget s m ()) where instance HamletValue (GWidget s m ()) where
newtype HamletMonad (GWidget s m ()) a = newtype HamletMonad (GWidget s m ()) a =

View File

@ -1,5 +1,5 @@
name: yesod name: yesod
version: 0.6.8 version: 0.7.0
license: BSD3 license: BSD3
license-file: LICENSE license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com> author: Michael Snoyman <michael@snoyman.com>
@ -36,7 +36,7 @@ library
, text >= 0.5 && < 0.12 , text >= 0.5 && < 0.12
, template-haskell >= 2.4 && < 2.6 , template-haskell >= 2.4 && < 2.6
, web-routes-quasi >= 0.6.2 && < 0.7 , web-routes-quasi >= 0.6.2 && < 0.7
, hamlet >= 0.5.1 && < 0.7 , hamlet >= 0.6 && < 0.7
, blaze-builder >= 0.2.1 && < 0.3 , blaze-builder >= 0.2.1 && < 0.3
, transformers >= 0.2 && < 0.3 , transformers >= 0.2 && < 0.3
, clientsession >= 0.4.0 && < 0.5 , clientsession >= 0.4.0 && < 0.5
@ -45,8 +45,8 @@ library
, cereal >= 0.2 && < 0.4 , cereal >= 0.2 && < 0.4
, base64-bytestring >= 0.1 && < 0.2 , base64-bytestring >= 0.1 && < 0.2
, old-locale >= 1.0.0.2 && < 1.1 , old-locale >= 1.0.0.2 && < 1.1
, persistent >= 0.3.0 && < 0.4 , persistent >= 0.4 && < 0.5
, neither >= 0.1.0 && < 0.2 , neither >= 0.2 && < 0.3
, network >= 2.2.1.5 && < 2.4 , network >= 2.2.1.5 && < 2.4
, email-validate >= 0.2.5 && < 0.3 , email-validate >= 0.2.5 && < 0.3
, web-routes >= 0.23 && < 0.24 , web-routes >= 0.23 && < 0.24
@ -54,6 +54,7 @@ library
, data-default >= 0.2 && < 0.3 , data-default >= 0.2 && < 0.3
, failure >= 0.1 && < 0.2 , failure >= 0.1 && < 0.2
, containers >= 0.2 && < 0.5 , containers >= 0.2 && < 0.5
, monad-peel >= 0.1 && < 0.2
exposed-modules: Yesod exposed-modules: Yesod
Yesod.Content Yesod.Content
Yesod.Dispatch Yesod.Dispatch