Permalink
Browse files

MonadLift instance for AForm

  • Loading branch information...
snoyberg committed Sep 19, 2012
1 parent fef3024 commit 0c68f46762b957f20a98a65acd2bc6cc31322d43
Showing with 7 additions and 2 deletions.
  1. +6 −1 yesod-form/Yesod/Form/Types.hs
  2. +1 −1 yesod-form/yesod-form.cabal
@@ -2,6 +2,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE CPP #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
module Yesod.Form.Types
( -- * Helpers
Enctype (..)
@@ -30,7 +31,7 @@ import Text.Blaze (Markup, ToMarkup (toMarkup))
import Control.Applicative ((<$>), Applicative (..))
import Control.Monad (liftM)
import Data.String (IsString (..))
-import Yesod.Core (GHandler, GWidget, SomeMessage)
+import Yesod.Core (GHandler, GWidget, SomeMessage, MonadLift (..))
import qualified Data.Map as Map
-- | A form can produce three different results: there was no data available,
@@ -97,6 +98,10 @@ instance Applicative (AForm sub master) where
instance Monoid a => Monoid (AForm sub master a) where
mempty = pure mempty
mappend a b = mappend <$> a <*> b
+instance MonadLift (GHandler sub master) (AForm sub master) where
+ lift f = AForm $ \_ _ ints -> do
+ x <- f
+ return (FormSuccess x, id, ints, mempty)
data FieldSettings master = FieldSettings
{ fsLabel :: SomeMessage master
@@ -1,5 +1,5 @@
name: yesod-form
-version: 1.1.1.2
+version: 1.1.2
license: MIT
license-file: LICENSE
author: Michael Snoyman <michael@snoyman.com>

0 comments on commit 0c68f46

Please sign in to comment.