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$ %dd $snd$
|] |]
json (ident, dn) = json (ident, dn) =
jsonMap [ (jsonScalar $ cs "ident", jsonScalar ident) jsonMap [ ("ident", jsonScalar ident)
, (jsonScalar $ cs "displayName", jsonScalar dn) , ("displayName", jsonScalar dn)
] ]
getLogout :: GHandler Auth master () getLogout :: GHandler Auth master ()

View File

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

View File

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

View File

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