From 7825b27d262af7252b48e9179a5bbf86b0f30d22 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 10 Oct 2015 11:22:03 +0200 Subject: More readable birthdates in csv file --- src/Mail.hs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/Mail.hs') 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." ] -- cgit v1.2.3