Skip to content

Commit

Permalink
Fix one issue
Browse files Browse the repository at this point in the history
  • Loading branch information
The1Penguin committed Jun 1, 2024
1 parent 5b4e3c7 commit b6fa09e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Model/Linsen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ parse day =
( withObject "Parse meals"
$ (.: "docs")
>=> ((!? (6 - (day ^. weekDate . _wdDay))) <&> \case
Nothing -> fail "Day doesnt exist"
Nothing -> fail "Day doesnt exist" -- TODO: Should early return to shortcircuit to []
Just v -> pure v)
>=> (.: "richText")
>=> (.: "root")
>=> (.: "children")
>=> pure . (\v -> if length v >= 9 then v else mempty)
>=> menuParser
)
)
Expand All @@ -82,7 +83,8 @@ parse day =
(2 ,vs) -> [vs] -- Index of Meat dish
(6 ,vs) -> [vs] -- Index of Fish dish
(10,vs) -> [vs] -- Index of Veg dish
_ -> []) <=< ap (zipWithM sumFood) tail
_ -> [])
<=< ap (zipWithM sumFood) tail

sumFood :: Value -> Value -> Parser Menu
sumFood a b = Menu <$> getFood a <*> getFood b
Expand Down

0 comments on commit b6fa09e

Please sign in to comment.