aboutsummaryrefslogtreecommitdiff
path: root/src/Mail.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mail.hs')
-rw-r--r--src/Mail.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Mail.hs b/src/Mail.hs
index 7bb6814..dc533ef 100644
--- a/src/Mail.hs
+++ b/src/Mail.hs
@@ -27,9 +27,9 @@ mailSubject birthdates =
mailBody :: Date -> [Birthdate] -> Text
mailBody currentDate birthdates =
let count = length birthdates
- birthdatesWithLines = map (mapFst getLine) . zip [1..] $ birthdates
- getLine 1 = if count == 1 then SingleLine else FirstLine
- getLine line = if line == count then LastLine else MiddleLine
+ 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)
@@ -43,33 +43,33 @@ data Line =
deriving (Eq, Show)
mailLine :: Date -> (Line, Birthdate) -> Text
-mailLine date (SingleLine, birthdate) =
+mailLine currDate (SingleLine, birthdate) =
T.concat
[ fullname birthdate
, " is now "
- , T.pack . show $ age date birthdate
+ , T.pack . show $ age currDate birthdate
, " years old."
]
-mailLine date (FirstLine, birthdate) =
+mailLine currDate (FirstLine, birthdate) =
T.concat
[ fullname birthdate
, " is now "
- , T.pack . show $ age date birthdate
+ , T.pack . show $ age currDate birthdate
, " years old"
]
-mailLine date (MiddleLine, birthdate) =
+mailLine currDate (MiddleLine, birthdate) =
T.concat
[ ", "
, fullname birthdate
, " is "
- , T.pack . show $ age date birthdate
+ , T.pack . show $ age currDate birthdate
, " years old"
]
-mailLine date (LastLine, birthdate) =
+mailLine currDate (LastLine, birthdate) =
T.concat
[ " and "
, fullname birthdate
, " is "
- , T.pack . show $ age date birthdate
+ , T.pack . show $ age currDate birthdate
, " years old."
]