packages feed

happstack-static-routing 0.1 → 0.2

raw patch · 2 files changed

+7/−7 lines, 2 files

Files

happstack-static-routing.cabal view
@@ -1,5 +1,5 @@ Name:                happstack-static-routing-Version:             0.1+Version:             0.2 Synopsis: Support for static URL routing with overlap detection for Happstack.  Description: If you have a large routing table in Happstack and want
src/Happstack/StaticRouting/Internal.hs view
@@ -35,17 +35,17 @@ type EndSegment = (Maybe Int, H.Method)  -- | Support for varying number of arguments to 'path' handlers.-class Path m a b | a -> m b where+class Path m a b | a b -> m where   pathHandler :: (m b -> m c) -> a -> m c-  arity :: a -> Int+  arity :: m b -> a -> Int  instance (FromReqURI d, ServerMonad m, MonadPlus m, Path m a b) => Path m (d -> a) b where   pathHandler w f = H.path (pathHandler w . f)-  arity f = 1 + arity (f undefined)+  arity m f = 1 + arity m (f undefined)  instance Path m (m b) b where   pathHandler w m = w m-  arity _ = 0+  arity _ _ = 0  -- | Pop a path element if it matches the given string. dir :: String -> Route a -> Route a@@ -56,8 +56,8 @@ choice = Choice  -- | Expect the given method, and exactly 'n' more segments, where 'n' is the arity of the handler.-path :: Path m h a => H.Method -> (m a -> m b) -> h -> Route (m b)-path m w h = Handler (Just (arity h),m) (pathHandler w h)+path :: forall m h a b. Path m h a => H.Method -> (m a -> m b) -> h -> Route (m b)+path m w h = Handler (Just (arity (undefined::m a) h),m) (pathHandler w h)  -- | Expect zero or more segments. remainingPath :: H.Method -> h -> Route h