Skip to content

Commit

Permalink
Cleaner code ;P
Browse files Browse the repository at this point in the history
  • Loading branch information
The1Penguin committed Jun 5, 2024
1 parent 3c5785f commit 1a320f2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 deletions.
1 change: 1 addition & 0 deletions mat-chalmers.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ library
, thyme >= 0.4 && <= 0.5
, word8 == 0.1.3
, extra >= 1.7.10 && <= 1.8
, vector-space >= 0.16 && <0.18

executable mat-chalmers
main-is: Main.hs
Expand Down
5 changes: 2 additions & 3 deletions src/Model.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ import Data.Text.Lazy ( fromStrict
import Prettyprinter ( Doc
, pretty
)
import Data.AffineSpace ( (.+^) )
import Data.Thyme ( _localDay
, _localTimeOfDay
, _todHour
, _zonedTimeToLocalTime
, getZonedTime
, gregorian
)
import Lens.Micro.Platform ( (^.)
, (&)
Expand All @@ -56,7 +56,6 @@ import Model.Types
import Model.Karen
import Model.Wijkanders
import Model.Linsen
import Util ( nextDay )

-- | Refreshes menus.
-- The refresh function evaluates to `Some monad m => m (View model, Update signal)`,
Expand Down Expand Up @@ -94,7 +93,7 @@ update = do
let (textday, d) =
if dateNow ^. _localTimeOfDay . _todHour >= nextDayHour
then
("Tomorrow", dateNow & (_localDay . gregorian) %~ nextDay)
("Tomorrow", dateNow & _localDay %~ (.+^ 1))
else ("Today", dateNow)
let day' = d ^. _localDay
let karenR = fetchAndCreateRestaurant day'
Expand Down
10 changes: 0 additions & 10 deletions src/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Util where
import Data.ByteString.Lazy ( ByteString )
import qualified Data.ByteString.Lazy as BL
import qualified Data.Word8 as W8
import Data.Thyme.Calendar

import Text.HTML.TagSoup ( Tag
, isTagText
Expand All @@ -30,12 +29,3 @@ removeWhitespaceTags :: [Tag ByteString] -> [Tag ByteString]
removeWhitespaceTags =
filter (\t -> not (isTagText t) || tagText (not . BL.all W8.isSpace) t)

-- | Increase the date by one with and handles overflow
-- I cannot believe that this isn't in the library
nextDay :: YearMonthDay -> YearMonthDay
nextDay (YearMonthDay y m d)
| d < len = YearMonthDay y m (d + 1)
| m < 12 = YearMonthDay y (m + 1) 1
| otherwise = YearMonthDay (y + 1) 1 1
where
len = gregorianMonthLength y m

0 comments on commit 1a320f2

Please sign in to comment.