From 95298f856e47715106fbf744e2f363bc39584329 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 4 May 2019 18:25:06 +0200 Subject: [PATCH] Fix hlint --- src/Handler/Material.hs | 23 +++++++++++------------ src/Handler/Utils.hs | 2 +- src/Handler/Utils/DateTime.hs | 4 ++-- src/Handler/Utils/Table/Cells.hs | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Handler/Material.hs b/src/Handler/Material.hs index 56e696daf..7268f0f09 100644 --- a/src/Handler/Material.hs +++ b/src/Handler/Material.hs @@ -48,10 +48,10 @@ makeMaterialForm cid template = identifyForm FIDmaterial $ \html -> do previouslyUsed <- liftHandlerT . runDB $ E.select $ E.from $ \material -> E.distinctOnOrderBy [E.asc $ material E.^. MaterialType] $ do - E.where_ $ (material E.^. MaterialCourse E.==. E.val cid) - E.&&. (E.not_ $ E.isNothing $ material E.^. MaterialType) + E.where_ $ material E.^. MaterialCourse E.==. E.val cid + E.&&. E.not_ (E.isNothing $ material E.^. MaterialType) return $ material E.^. MaterialType - return $ defaults <> (Set.fromList $ mapMaybe E.unValue previouslyUsed) + return $ defaults <> Set.fromList (mapMaybe E.unValue previouslyUsed) ctime <- ceilingQuarterHour <$> liftIO getCurrentTime flip (renderAForm FormStandard) html $ MaterialForm @@ -88,7 +88,7 @@ getMaterialListR tid ssh csh = do cid <- getKeyBy404 $ TermSchoolCourseShort tid ssh csh let row2material = entityVal . dbrOutput -- no inner join, just Entity Material psValidator = def & defaultSorting [SortDescBy "last-edit"] - table <- dbTableWidget' psValidator DBTable + dbTableWidget' psValidator DBTable { dbtIdent = "material-list" :: Text , dbtStyle = def , dbtParams = def @@ -120,10 +120,9 @@ getMaterialListR tid ssh csh = do , dbtFilter = mempty , dbtFilterUI = mempty } - return table - let headingLong = prependCourseTitle tid ssh csh $ MsgMaterialListHeading - headingShort = prependCourseTitle tid ssh csh $ MsgMaterialListHeading + let headingLong = prependCourseTitle tid ssh csh MsgMaterialListHeading + headingShort = prependCourseTitle tid ssh csh MsgMaterialListHeading siteLayoutMsg headingLong $ do setTitleI headingShort $(widgetFile "material-list") @@ -152,7 +151,7 @@ getMShowR :: TermId -> SchoolId -> CourseShorthand -> MaterialName -> Handler Ht getMShowR tid ssh csh mnm = do let matLink :: FilePath -> Route UniWorX matLink = CourseR tid ssh csh . MaterialR mnm . MFileR - ( (Entity _mid material@Material{materialType, materialDescription}) + ( Entity _mid material@Material{materialType, materialDescription} , (Any hasFiles,fileTable)) <- runDB $ do matEnt <- fetchMaterial tid ssh csh mnm let psValidator = def & defaultSortingByFileTitle @@ -182,7 +181,7 @@ getMShowR tid ssh csh mnm = do return (matEnt,fileTable') let matVisFro = materialVisibleFrom material - now <- liftIO $ getCurrentTime + now <- liftIO getCurrentTime materialLastEdit <- formatTime SelFormatDateTime $ materialLastEdit material materialVisibleFrom <- traverse (formatTime SelFormatDateTime) matVisFro when (NTop matVisFro >= NTop (Just now)) $ addMessageI Warning $ @@ -206,7 +205,7 @@ postMEditR tid ssh csh mnm = do return $ file E.^. FileId return (matEnt, (Left . E.unValue) <$> fileIds) -- let cid = materialCourse - let template = Just $ MaterialForm + let template = Just MaterialForm { mfName = materialName , mfType = materialType , mfDescription = materialDescription @@ -274,7 +273,7 @@ handleMaterialEdit tid ssh csh cid template dbMaterial = do return $ file E.^. FileId let oldFileIds = setFromList $ map E.unValue oldFileIdVals keep <- execWriterT . runConduit $ transPipe (lift . lift) fs =$= C.mapM_ finsert - mapM_ deleteCascade $ (oldFileIds \\ keep :: Set FileId) + mapM_ deleteCascade (oldFileIds \\ keep :: Set FileId) where finsert (Left fileId) = tell $ singleton fileId finsert (Right file) = lift $ do @@ -299,4 +298,4 @@ postMDelR tid ssh csh mnm = do , drSuccess = SomeRoute $ CourseR tid ssh csh MaterialListR , drAbort = SomeRoute $ CourseR tid ssh csh $ MaterialR mnm MShowR } - -} \ No newline at end of file + -} diff --git a/src/Handler/Utils.hs b/src/Handler/Utils.hs index dfca11b4c..8e2a595e2 100644 --- a/src/Handler/Utils.hs +++ b/src/Handler/Utils.hs @@ -52,7 +52,7 @@ serveOneFile :: DB [Entity File] -> Handler TypedContent serveOneFile query = do results <- runDB query case results of - [(Entity _fileId File{fileTitle, fileContent})] + [Entity _fileId File{fileTitle, fileContent}] | Just fileContent' <- fileContent -> do whenM downloadFiles $ addHeader "Content-Disposition" [st|attachment; filename="#{takeFileName fileTitle}"|] diff --git a/src/Handler/Utils/DateTime.hs b/src/Handler/Utils/DateTime.hs index 2b8e5af46..16ab29afa 100644 --- a/src/Handler/Utils/DateTime.hs +++ b/src/Handler/Utils/DateTime.hs @@ -203,5 +203,5 @@ ceilingMinuteBy margin roundto utct = addUTCTime bonus utct oldTime = localTimeOfDay $ utcToLocalTime utct oldMin = todMin oldTime newMin = roundToNearestMultiple roundto $ oldMin + margin - newTime = oldTime { todMin = newMin, todSec = 0} -- might be invalid, but correctly treated by `timeOfDayToTime` - bonus = realToFrac $ (timeOfDayToTime newTime) - (timeOfDayToTime oldTime) \ No newline at end of file + newTime = oldTime { todMin = newMin, todSec = 0 } -- might be invalid, but correctly treated by `timeOfDayToTime` + bonus = realToFrac $ timeOfDayToTime newTime - timeOfDayToTime oldTime diff --git a/src/Handler/Utils/Table/Cells.hs b/src/Handler/Utils/Table/Cells.hs index 5f7a29e52..84580b219 100644 --- a/src/Handler/Utils/Table/Cells.hs +++ b/src/Handler/Utils/Table/Cells.hs @@ -55,7 +55,7 @@ sqlCell act = mempty & cellContents .~ lift act markCell :: (IsDBTable m a) => (a -> Bool) -> (a -> DBCell m a) -> a -> DBCell m a markCell condition normal x - | condition x = (normal x) <> (cell $ isVisibleWidget False) + | condition x = normal x <> cell (isVisibleWidget False) | otherwise = normal x