Skip to content

Commit

Permalink
MultiWayIf is even cooler than combining case and pattern guards
Browse files Browse the repository at this point in the history
  • Loading branch information
Rembane committed Sep 26, 2024
1 parent eac7f2e commit db3740f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Model/Linsen.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE FlexibleContexts, OverloadedStrings, LambdaCase #-}
{-# LANGUAGE FlexibleContexts, LambdaCase, MultiWayIf, OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}

module Model.Linsen
Expand Down Expand Up @@ -118,10 +118,10 @@ parse day =
(v:_) -> pure v)
>=> (.: "text")
>=> \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"))
let sameDay = pure day == parseTime swedishTimeLocale "%A %d-%m-%Y" s
in if | sameDay && length v' >= 9 -> pure v'
| sameDay -> pure mempty
| otherwise -> fail "Unable to parse day"))
>=> menuParser
)
)
Expand Down

0 comments on commit db3740f

Please sign in to comment.