Better type for jsonmap

This commit is contained in:
Michael Snoyman 2010-05-02 07:09:28 +03:00
parent de7ed94abd
commit dda3140695
4 changed files with 11 additions and 7 deletions

View File

@ -170,8 +170,8 @@ getCheck = do
%dd $snd$
|]
json (ident, dn) =
jsonMap [ (jsonScalar $ cs "ident", jsonScalar ident)
, (jsonScalar $ cs "displayName", jsonScalar dn)
jsonMap [ ("ident", jsonScalar ident)
, ("displayName", jsonScalar dn)
]
getLogout :: GHandler Auth master ()

View File

@ -23,6 +23,7 @@ module Yesod.Helpers.Static
, fileLookupDir
, siteStatic
, StaticRoutes
, toStaticRoute
, staticArgs
, Static
) where
@ -80,3 +81,6 @@ getStaticRoute :: [String] -> GHandler Static master [(ContentType, Content)]
getStaticRoute fp = do
Static fl <- getYesod
getStatic fl fp
toStaticRoute :: [String] -> StaticRoutes
toStaticRoute = StaticRoute

View File

@ -18,7 +18,7 @@ module Yesod.Json
import Text.Hamlet.Monad
import Control.Applicative
import Data.Text (Text)
import Data.Text (Text, pack)
import Web.Encodings
import Yesod.Hamlet
import Yesod.Definitions
@ -66,10 +66,10 @@ jsonList' (Enumerator enum) = do
() <- j
return $ Right True
jsonMap :: [(Json url (), Json url ())] -> Json url ()
jsonMap :: [(String, Json url ())] -> Json url ()
jsonMap = jsonMap' . fromList
jsonMap' :: Enumerator (Json url (), Json url ()) (Json url) -> Json url () -- FIXME simplify type
jsonMap' :: Enumerator (String, Json url ()) (Json url) -> Json url () -- FIXME simplify type
jsonMap' (Enumerator enum) = do
Json $ outputString "{"
_ <- enum go False
@ -77,7 +77,7 @@ jsonMap' (Enumerator enum) = do
where
go putComma (k, v) = do
when putComma $ Json $ outputString ","
() <- k
jsonScalar $ Unencoded $ pack k
Json $ outputString ":"
() <- v
return $ Right True

View File

@ -53,7 +53,7 @@ library
template-haskell,
web-routes >= 0.22 && < 0.23,
web-routes-quasi >= 0.0 && < 0.1,
hamlet >= 0.0 && < 0.1
hamlet >= 0.0.1 && < 0.1
if flag(transformers_02)
build-depends: transformers >= 0.2 && < 0.3
CPP-OPTIONS: -DTRANSFORMERS_02