From 291064c03bd15ed7d7b07b64618fced601fc582b Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Sun, 24 Mar 2019 12:04:36 +0100 Subject: [PATCH] MINOR linter problems and curried rowWdgt -> uncurried rowWgt (obfuscates my Anwer to Felix' question, hence different commit) --- src/Handler/Admin.hs | 4 ++-- src/Handler/Utils/SheetType.hs | 2 +- src/Utils.hs | 11 +++++++++-- .../widgets/grading-summary/grading-summary.hamlet | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Handler/Admin.hs b/src/Handler/Admin.hs index 9ef15cb84..6e57fd206 100644 --- a/src/Handler/Admin.hs +++ b/src/Handler/Admin.hs @@ -196,8 +196,8 @@ postAdminTestR = do allowAdd _ _ l = l < 7 -- Limit list length; much more complicated checks are possible (this could in principle be monadic, but @massInput@ is probably already complicated enough to cover just current (2019-03) usecases) -- The actual call to @massInput@ is comparatively simple: - - ((miResult, (fvInput -> miForm)), miEnc) <- runFormPost . identifyForm ("massinput" :: Text) $ massInput (MassInput mkAddForm mkCellForm deleteCell allowAdd) "" True Nothing + + ((miResult, fvInput -> miForm), miEnc) <- runFormPost . identifyForm ("massinput" :: Text) $ massInput (MassInput mkAddForm mkCellForm deleteCell allowAdd) "" True Nothing let locallyDefinedPageHeading = [whamlet|Admin TestPage for Uni2work|] diff --git a/src/Handler/Utils/SheetType.hs b/src/Handler/Utils/SheetType.hs index de10d4d8b..a4cd057b3 100644 --- a/src/Handler/Utils/SheetType.hs +++ b/src/Handler/Utils/SheetType.hs @@ -25,7 +25,7 @@ gradeSummaryWidget title sts = hasMarkedPasses = positiveSum $ numMarkedPasses sumSummaries hasPoints = positiveSum $ numSheetsPoints sumSummaries hasMarkedPoints = positiveSum $ numMarkedPoints sumSummaries - rowWdgt sumHeader summary = $(widgetFile "widgets/grading-summary/grading-summary-row") -- diese Funktonsdefinition darf leider nicht im .hamlet stehen! + rowWgt (sumHeader, summary) = $(widgetFile "widgets/grading-summary/grading-summary-row") -- diese Funktonsdefinition darf leider nicht im .hamlet stehen! rowsShown = [ (MsgSheetTypeNormal' ,normalSummary) , (MsgSheetTypeBonus' ,bonusSummary) , (MsgSheetTypeInformational' ,informationalSummary) diff --git a/src/Utils.hs b/src/Utils.hs index 8c08d999c..24bf6c423 100644 --- a/src/Utils.hs +++ b/src/Utils.hs @@ -591,12 +591,19 @@ mconcatMapM f = foldM (\x my -> mappend x <$> my) mempty . map f . Fold.toList mconcatForM :: (Monoid b, Monad m, Foldable f) => f a -> (a -> m b) -> m b mconcatForM = flip mconcatMapM + + ----------------- -- Alternative -- ----------------- -choice :: forall f mono a. (Alternative f, MonoFoldable mono, Element mono ~ f a) => mono -> f a -choice = foldr (<|>) empty +-- Linter complains to use asum instead, but requires a more specific type signature: +-- choice :: forall f mono a. (Alternative f, MonoFoldable mono, Element mono ~ f a) => mono -> f a +-- choice = foldr (<|>) empty +choice :: (Foldable t, Alternative f) => t (f a) -> f a +choice = asum -- + + -------------- -- Sessions -- diff --git a/templates/widgets/grading-summary/grading-summary.hamlet b/templates/widgets/grading-summary/grading-summary.hamlet index a4d320491..8432448d6 100644 --- a/templates/widgets/grading-summary/grading-summary.hamlet +++ b/templates/widgets/grading-summary/grading-summary.hamlet @@ -24,8 +24,8 @@ $# -- _{MsgSheetGradingPoints'} _{MsgSheetGradingCount'} $# Number of Sheet/Submissions used for calculating maximum passes/points - $forall (headMsg, summaryVal) <- rowsShown - ^{rowWdgt headMsg summaryVal} + $forall someRow <- rowsShown + ^{rowWgt someRow} $maybe nrNoGrade <- positiveSum $ numNotGraded _{MsgSheetTypeNotGraded}