From 03616513d2f2f2d73491ba34fa96dcc2702792d2 Mon Sep 17 00:00:00 2001 From: Andreas Ekeroot Date: Wed, 25 Sep 2024 22:11:21 +0200 Subject: [PATCH] A shorter double-if variant using pattern matching and guards --- src/Model/Linsen.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Model/Linsen.hs b/src/Model/Linsen.hs index 70beead..bb0d2d9 100644 --- a/src/Model/Linsen.hs +++ b/src/Model/Linsen.hs @@ -117,12 +117,11 @@ parse day = [] -> fail "Failed to index into richtext" (v:_) -> pure v) >=> (.: "text") - >=> \s -> if - pure day == parseTime swedishTimeLocale "%A %d-%m-%Y" s - then if length v' >= 9 - then pure v' - else pure mempty - else fail "Unable to parse day")) + >=> \s -> + case pure day == parseTime swedishTimeLocale "%A %d-%m-%Y" s of + True | length v' >= 9 -> pure v' + | otherwise -> pure mempty + False -> fail "Unable to parse day")) >=> menuParser ) )