web-routes-boomerang 0.27.1 → 0.28.4.5
raw patch · 2 files changed
Files
- Web/Routes/Boomerang.hs +11/−11
- web-routes-boomerang.cabal +18/−11
Web/Routes/Boomerang.hs view
@@ -22,7 +22,7 @@ > import Prelude hiding (id, (.)) > import Control.Category (Category(id, (.))) > import Control.Monad.Trans (MonadIO(liftIO))-> import Text.Boomerang.TH (derivePrinterParsers)+> import Text.Boomerang.TH (makeBoomerangs) > import Web.Routes (Site(..), RouteT(..), decodePathInfo, encodePathInfo, runSite, showURL) > import Web.Routes.Boomerang (Router, (<>), (</>), int, parse1, boomerangSiteRouteT, anyString, parseStrings) @@ -37,9 +37,9 @@ > deriving (Eq, Show) -To use the 'Sitemap' type with @boomerang@ we need to call 'derivePrinterParsers':+To use the 'Sitemap' type with @boomerang@ we need to call 'makeBoomerangs': -> $(derivePrinterParsers ''Sitemap)+> $(makeBoomerangs ''Sitemap) That will create new combinators corresponding to the constructors for 'Sitemap'. They will be named, @rHome@, @rUserOverview@, etc.@@ -154,20 +154,20 @@ import Data.List (maximumBy) import Data.Text (Text, pack, unpack) import qualified Data.Text as T-import Text.Boomerang -- (PrinterParser(..), ParserError(..), (:-), condenseErrors, parse1, showParserError, unparse1)-import Text.Boomerang.Texts -- (StringsPos(..), isComplete)+import Text.Boomerang+import Text.Boomerang.Texts import Text.ParserCombinators.Parsec.Prim (State(..), getParserState, setParserState) import Text.Parsec.Pos (sourceLine, sourceColumn, setSourceColumn, setSourceLine) import Web.Routes (RouteT(..), Site(..), PathInfo(..), URLParser) --- | 'Router a b' is a simple type alias for 'PrinterParser TextsError [Text] a b'-type Router a b = PrinterParser TextsError [Text] a b+-- | 'Router a b' is a simple type alias for 'Boomerang TextsError [Text] a b'+type Router a b = Boomerang TextsError [Text] a b -- | function which creates a 'Site' from a 'Router' and a handler boomerangSite :: ((url -> [(Text, Maybe Text)] -> Text) -> url -> a) -- ^ handler function -> Router () (url :- ()) -- ^ the router -> Site url a-boomerangSite handler r@(PrinterParser pf sf) =+boomerangSite handler r@(Boomerang pf sf) = Site { handleSite = handler , formatPathSegments = \url -> case unparseTexts r url of@@ -187,8 +187,8 @@ boomerangSiteRouteT handler router = boomerangSite (flip $ unRouteT . handler) router -- | convert to a 'URLParser' so we can create a 'PathInfo' instance-boomerangFromPathSegments :: PrinterParser TextsError [Text] () (url :- ()) -> URLParser url-boomerangFromPathSegments (PrinterParser prs _) =+boomerangFromPathSegments :: Boomerang TextsError [Text] () (url :- ()) -> URLParser url+boomerangFromPathSegments (Boomerang prs _) = do st <- getParserState let results = runParser prs (stateInput st) (MajorMinorPos (fromIntegral $ sourceLine (statePos st)) (fromIntegral $ sourceColumn (statePos st))) successes = [ ((f (), tok), pos) | (Right ((f, tok), pos)) <- results]@@ -206,7 +206,7 @@ trim (t:ts) = if T.null t then ts else (t:ts) -- | convert to the type expected by 'toPathSegments' from 'PathInfo'-boomerangToPathSegments :: PrinterParser TextsError [Text] () (url :- ()) -> (url -> [Text])+boomerangToPathSegments :: Boomerang TextsError [Text] () (url :- ()) -> (url -> [Text]) boomerangToPathSegments pp = \url -> case unparse1 [] pp url of Nothing -> error $ "boomerangToPathSegments: could not convert url to [Text]"
web-routes-boomerang.cabal view
@@ -1,27 +1,34 @@ Name: web-routes-boomerang-Version: 0.27.1+Version: 0.28.4.5 License: BSD3 License-File: LICENSE Author: jeremy@seereason.com Maintainer: partners@seereason.com Bug-Reports: http://bugzilla.seereason.com/ Category: Web, Language-Synopsis: Library for maintaining correctness and composability of URLs within an application.+Synopsis: Use boomerang for type-safe URL parsers/printers Description: This module add support for creating url parsers/printers using a single unified grammar specification-Cabal-Version: >= 1.6+Cabal-Version: >= 1.10 Build-type: Simple+tested-with: GHC==8.0.2, GHC==8.2.2, GHC==8.4.1, GHC==8.6.5, GHC==8.8.4, GHC==8.10.7, GHC==9.0.2, GHC==9.2.5, GHC==9.4.8, GHC==9.6.4, GHC==9.8.1 +source-repository head+ type: git+ location: https://github.com/happstack/web-routes-boomerang++ Library- Build-Depends: base >= 4 && < 5,- boomerang >= 1.3.2,- mtl,+ Default-Language: Haskell2010+ Build-Depends: base >= 4.9 && < 5,+ boomerang >= 1.4 && < 1.5,+ mtl < 2.4, parsec == 3.1.*,- text == 0.11.*,- web-routes >= 0.26+ text >= 0.11 && < 2.2,+ web-routes >= 0.26 && < 0.28 Exposed-Modules: Web.Routes.Boomerang - Extensions: TypeOperators+ Other-Extensions: TemplateHaskell, TypeOperators, OverloadedStrings source-repository head- type: darcs- location: http://hub.darcs.net/stepcut/web-routes+ type: git+ location: https://github.com/Happstack/web-routes-boomerang.git