From 910997e366d146d534585a378679859199815acf Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 8 Mar 2017 15:04:59 +0100 Subject: Modify mailStr with bytestring operations --- src/Simple.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Simple.hs b/src/Simple.hs index 68524a8..80856d3 100644 --- a/src/Simple.hs +++ b/src/Simple.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE RecordWildCards, ApplicativeDo, FlexibleContexts #-} +{-# LANGUAGE RecordWildCards, ApplicativeDo, FlexibleContexts, ViewPatterns, OverloadedStrings #-} module Main (main) where @@ -51,15 +51,16 @@ main = do ] flip runReaderT sConfig $ do - mailStr <- liftIO getContents - delay <- scan mailStr + mailStr <- liftIO Lazy.BS.getContents + delay <- scan $ Lazy.Char8.BS.unpack mailStr let - (headers, body) = break (== "") $ lines mailStr - mailStr' = unlines $ filter (not . (isPrefixOf `on` CI.foldCase) "X-Delay:") headers ++ body + (headers, body) = break (== "") $ Lazy.Char8.BS.lines mailStr + headers' = filter (not . (Lazy.Char8.BS.isPrefixOf `on` CI.foldCase) "X-Delay:") headers + mailStr' = Lazy.Char8.BS.unlines $ headers' ++ body - sendNow = sendmail sender recipients $ Lazy.Char8.BS.pack mailStr' + sendNow = sendmail sender recipients mailStr' sendLater sendDelay = pushStore . yield $ StoredMail - { message = Lazy.Char8.BS.pack mailStr' + { message = mailStr' , .. } maybe sendNow sendLater delay -- cgit v1.2.3