]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Router.hs
working on Router arrow
[Lucu.git] / Network / HTTP / Lucu / Router.hs
index 7c9c8055e56c81b1dbb9a5f4ac8e36e591255a37..657df3bb19cc76ea748edd0c008324a991c0c55c 100644 (file)
@@ -12,6 +12,7 @@ module Network.HTTP.Lucu.Router
     , runRouter
 
       -- * Testing for URI scheme
+    , anyScheme
     , schemeWith
     , scheme
     , http
@@ -50,6 +51,11 @@ runRouter ∷ (Applicative m, MonadIO m) ⇒ Router m α β → α → m (Maybe
 {-# INLINE runRouter #-}
 runRouter = ((listToMaybe <$>) ∘) ∘ runListTArrow ∘ unRouter
 
+-- |FIXME: doc
+anyScheme ∷ Arrow (⇝) ⇒ URI ⇝ (Host, Path)
+{-# INLINEABLE anyScheme #-}
+anyScheme = arr uriHost &&& arr uriPathSegments
+
 -- |FIXME: doc
 schemeWith ∷ (ArrowChoice (⇝), ArrowZero (⇝))
            ⇒ (CIAscii → Bool)
@@ -58,7 +64,7 @@ schemeWith ∷ (ArrowChoice (⇝), ArrowZero (⇝))
 schemeWith f
     = proc uri →
       if f (uriCIScheme uri) then
-          arr uriHost &&& arr uriPathSegments ⤙ uri
+          anyScheme ⤙ uri
       else
           zeroArrow ⤙ (⊥)
 
@@ -72,10 +78,10 @@ http ∷ (ArrowChoice (⇝), ArrowPlus (⇝), ArrowZero (⇝)) ⇒ URI ⇝ (Host
 {-# 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"