aboutsummaryrefslogtreecommitdiff
path: root/src/Mail.hs
diff options
context:
space:
mode:
authorJoris2015-11-21 21:41:38 +0100
committerJoris2015-11-21 21:41:38 +0100
commit5375ad26dd78220185f1ffe05222250c06dc1a0c (patch)
tree30998d4fe19206e8c5c9e564db116d2022e5e313 /src/Mail.hs
parent7acd7a42f7663aa79d18e24bdb9fe19bf15f8fae (diff)
downloadevents-5375ad26dd78220185f1ffe05222250c06dc1a0c.tar.gz
events-5375ad26dd78220185f1ffe05222250c06dc1a0c.tar.bz2
events-5375ad26dd78220185f1ffe05222250c06dc1a0c.zip
Get next week birthdays and send an empty mail for the moment
Diffstat (limited to 'src/Mail.hs')
-rw-r--r--src/Mail.hs75
1 files changed, 0 insertions, 75 deletions
diff --git a/src/Mail.hs b/src/Mail.hs
deleted file mode 100644
index dc533ef..0000000
--- a/src/Mail.hs
+++ /dev/null
@@ -1,75 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-
-module Mail
- ( mailSubject
- , mailBody
- ) where
-
-import Data.Text (Text)
-import qualified Data.Text as T
-
-import Date
-import Birthdate
-
-mailSubject :: [Birthdate] -> Text
-mailSubject birthdates =
- let count = length birthdates
- in T.concat
- [ "Hey, "
- , if count > 1 then "there are" else "there is"
- , " "
- , T.pack . show $ count
- , " birthday"
- , if count > 1 then "s" else ""
- , " today!"
- ]
-
-mailBody :: Date -> [Birthdate] -> Text
-mailBody currentDate birthdates =
- let count = length birthdates
- birthdatesWithLines = map (mapFst lineKind) . zip [1..] $ birthdates
- lineKind 1 = if count == 1 then SingleLine else FirstLine
- lineKind line = if line == count then LastLine else MiddleLine
- in T.concat $ map (mailLine currentDate) birthdatesWithLines
-
-mapFst :: (a -> c) -> (a, b) -> (c, b)
-mapFst f (x, y) = (f x, y)
-
-data Line =
- SingleLine
- | FirstLine
- | MiddleLine
- | LastLine
- deriving (Eq, Show)
-
-mailLine :: Date -> (Line, Birthdate) -> Text
-mailLine currDate (SingleLine, birthdate) =
- T.concat
- [ fullname birthdate
- , " is now "
- , T.pack . show $ age currDate birthdate
- , " years old."
- ]
-mailLine currDate (FirstLine, birthdate) =
- T.concat
- [ fullname birthdate
- , " is now "
- , T.pack . show $ age currDate birthdate
- , " years old"
- ]
-mailLine currDate (MiddleLine, birthdate) =
- T.concat
- [ ", "
- , fullname birthdate
- , " is "
- , T.pack . show $ age currDate birthdate
- , " years old"
- ]
-mailLine currDate (LastLine, birthdate) =
- T.concat
- [ " and "
- , fullname birthdate
- , " is "
- , T.pack . show $ age currDate birthdate
- , " years old."
- ]