X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FRouter.hs;h=8624f53aa8312d514f5ca9af0e2fe70366c85f89;hb=af68f61;hp=7c9c8055e56c81b1dbb9a5f4ac8e36e591255a37;hpb=7bb9f322d85c1d7d8f23044a1be3b7e3b0ebe5b7;p=Lucu.git diff --git a/Network/HTTP/Lucu/Router.hs b/Network/HTTP/Lucu/Router.hs index 7c9c805..8624f53 100644 --- a/Network/HTTP/Lucu/Router.hs +++ b/Network/HTTP/Lucu/Router.hs @@ -12,7 +12,7 @@ module Network.HTTP.Lucu.Router , runRouter -- * Testing for URI scheme - , schemeWith + , anyScheme , scheme , http , http' @@ -51,31 +51,29 @@ runRouter ∷ (Applicative m, MonadIO m) ⇒ Router m α β → α → m (Maybe runRouter = ((listToMaybe <$>) ∘) ∘ runListTArrow ∘ unRouter -- |FIXME: doc -schemeWith ∷ (ArrowChoice (⇝), ArrowZero (⇝)) - ⇒ (CIAscii → Bool) - → URI ⇝ (Host, Path) -{-# INLINEABLE schemeWith #-} -schemeWith f +anyScheme ∷ Arrow (⇝) ⇒ URI ⇝ (Host, Path) +{-# INLINEABLE anyScheme #-} +anyScheme = arr uriHost &&& arr uriPathSegments + +-- |FIXME: doc +scheme ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ CIAscii → URI ⇝ (Host, Path) +{-# INLINEABLE scheme #-} +scheme s = proc uri → - if f (uriCIScheme uri) then - arr uriHost &&& arr uriPathSegments ⤙ uri + if s ≡ uriCIScheme uri then + anyScheme ⤙ uri else zeroArrow ⤙ (⊥) --- |@'scheme' s@ = @'schemeWith' ('==' s)@ -scheme ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ CIAscii → URI ⇝ (Host, Path) -{-# INLINE scheme #-} -scheme = schemeWith ∘ (≡) - -- |@'http' = 'scheme' \"http\" '<+>' 'scheme' \"https\"@ http ∷ (ArrowChoice (⇝), ArrowPlus (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host, Path) {-# INLINE http #-} http = scheme "http" <+> scheme "https" --- |@'http'' = 'scheme' \"http\" +-- |@'http'' = 'scheme' \"http\"@ http' ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host, Path) http' = scheme "http" --- |@'https' = 'scheme' \"https\" +-- |@'https' = 'scheme' \"https\"@ https ∷ (ArrowChoice (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host, Path) https = scheme "https"