]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Router.hs
working on Router
[Lucu.git] / Network / HTTP / Lucu / Router.hs
index 7c9c8055e56c81b1dbb9a5f4ac8e36e591255a37..8624f53aa8312d514f5ca9af0e2fe70366c85f89 100644 (file)
@@ -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"