packages feed

route-generator 0.4 → 0.5

raw patch · 2 files changed

+11/−9 lines, 2 files

Files

route-generator.cabal view
@@ -1,5 +1,5 @@ name:            route-generator-version:         0.4+version:         0.5 cabal-version:   >= 1.8 license:         OtherLicense license-file:    COPYING
routeGenerator.hs view
@@ -63,19 +63,19 @@ emitPathHelpers rs nArgs = mapM_ emitPathHelper rs 	where 	doEscapeURI = escapeURIString (\c -> not (isReserved c || not (isUnescapedInURI c))) . T.unpack-	escapeURI = "(escapeURIString (\\c -> not (isReserved c || not (isUnescapedInURI c))) . unpack)"+	escapeURI = "(Network.URI.escapeURIString (\\c -> not (Network.URI.isReserved c || not (Network.URI.isUnescapedInURI c))) . Data.Text.unpack)" 	emitPathHelper r = do 		let args = argList "arg" (length (filter isDynamic (pieces r)) + multiArg r) 		T.putStr (target r) 		putStr "Path " 		putStr (unwords args)-		putStr " = URI \"\" Nothing ('/' : intercalate \"/\" (["+		putStr " = Network.URI.Partial.fromURI $ Network.URI.URI \"\" Nothing (Data.List.intercalate \"/\" ([" 		putStr $ intercalate ", " $ snd $ foldr (\p (n,xs) -> case p of-				Dynamic -> (n-1, (escapeURI ++ " $ toPathPiece arg" ++ show n):xs)+				Dynamic -> (n-1, (escapeURI ++ " $ Web.PathPieces.toPathPiece arg" ++ show n):xs) 				Static s -> (n, show (doEscapeURI s) : xs) 			) (length args - multiArg r, []) (pieces r) 		putStr "]"-		when (multi r) (putStr $ " ++ map " ++ escapeURI ++ " (toPathMultiPiece arg" ++ show (length args) ++ ")")+		when (multi r) (putStr $ " ++ map " ++ escapeURI ++ " (Web.PathPieces.toPathMultiPiece arg" ++ show (length args) ++ ")") 		putStrLn ")) \"\" \"\"" 		-- The where clause forces the typechecker to infer that our arguments 		-- are of the same type as the arguments of the action we map to.@@ -191,11 +191,13 @@ 			putStrLn "import Web.PathPieces (fromPathPiece, fromPathMultiPiece)" 			putStrLn "import Yesod.Routes.Dispatch (Route(..), Piece(Static, Dynamic))" +		-- Fully qualified to help when using with CPP 		when (PathHelpers `elem` flags) $ do-			putStrLn "import Data.List (intercalate)"-			putStrLn "import Network.URI (URI(..), escapeURIString, isReserved, isUnescapedInURI)"-			putStrLn "import Data.Text (unpack)"-			putStrLn "import Web.PathPieces (toPathPiece, toPathMultiPiece)"+			putStrLn "import qualified Data.List (intercalate)"+			putStrLn "import qualified Network.URI (URI(..), escapeURIString, isReserved, isUnescapedInURI)"+			putStrLn "import qualified Data.Text (unpack)"+			putStrLn "import qualified Web.PathPieces (toPathPiece, toPathMultiPiece)"+			putStrLn "import qualified Network.URI.Partial"  		putStrLn ""