]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Utils.hs
Unfoldable Dispatcher
[Lucu.git] / Network / HTTP / Lucu / Utils.hs
index 8722ecb1a7264ebd450dff106aa283b0d423de0b..1070d66f28042193a0337b02f1e9d858d63c9403 100644 (file)
@@ -8,7 +8,7 @@ module Network.HTTP.Lucu.Utils
     ( splitBy
     , quoteStr
     , parseWWWFormURLEncoded
-    , splitPathInfo
+    , uriPathSegments
     , trim
 
     , (⊲)
@@ -86,20 +86,20 @@ parseWWWFormURLEncoded src
                             )
     where
       unescape ∷ String → ByteString
-      unescape = Strict.pack ∘ unEscapeString ∘ map plusToSpace
+      unescape = Strict.pack ∘ unEscapeString ∘ (plusToSpace <$>)
 
       plusToSpace ∷ Char → Char
       plusToSpace '+' = ' '
       plusToSpace c   = c
 
--- |>>> splitPathInfo "http://example.com/foo/bar"
+-- |>>> uriPathSegments "http://example.com/foo/bar"
 -- ["foo", "bar"]
-splitPathInfo ∷ URI → [ByteString]
-splitPathInfo uri
+uriPathSegments ∷ URI → [ByteString]
+uriPathSegments uri
     = let reqPathStr = uriPath uri
           reqPath    = [unEscapeString x | x ← splitBy (≡ '/') reqPathStr, (¬) (null x)]
       in
-        map Strict.pack reqPath
+        Strict.pack <$> reqPath
 
 -- |>>> trim "  ab c d "
 -- "ab c d"
@@ -142,6 +142,5 @@ getLastModified = (clockTimeToUTC <$>) ∘ getModificationTime
     where
       clockTimeToUTC ∷ ClockTime → UTCTime
       clockTimeToUTC (TOD sec picoSec)
-          = posixSecondsToUTCTime
-            $ fromRational
+          = posixSecondsToUTCTime ∘ fromRational
             $ sec % 1 + picoSec % (1000 ⋅ 1000 ⋅ 1000 ⋅ 1000)