X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FUtils.hs;h=df19a76d251fdd42c66161e381ea6c45bece2be1;hp=7d6eeeb69531b73bede3d9e573c749c162c5e640;hb=e624f0db8c4610b36da9e4463a656e0cb8a104dd;hpb=1e48e402adec79653203dc19a1800efa7b1c467b diff --git a/Network/HTTP/Lucu/Utils.hs b/Network/HTTP/Lucu/Utils.hs index 7d6eeeb..df19a76 100644 --- a/Network/HTTP/Lucu/Utils.hs +++ b/Network/HTTP/Lucu/Utils.hs @@ -1,13 +1,17 @@ module Network.HTTP.Lucu.Utils ( splitBy -- (a -> Bool) -> [a] -> [[a]] + , joinWith -- [a] -> [[a]] -> [a] , trim -- (a -> Bool) -> [a] -> [a] , noCaseEq -- String -> String -> Bool , isWhiteSpace -- Char -> Bool ) where +import Control.Monad.Trans import Data.Char import Data.List +import Foreign +import Foreign.C splitBy :: (a -> Bool) -> [a] -> [[a]] @@ -17,6 +21,11 @@ splitBy isSeparator src (first, sep:rest) -> first : splitBy isSeparator rest +joinWith :: [a] -> [[a]] -> [a] +joinWith separator xs + = foldr (++) [] $ intersperse separator xs + + trim :: (a -> Bool) -> [a] -> [a] trim p = trimTail . trimHead where