cln: hlint: Remove Either and Bifunctor related warnings.
This commit is contained in:
parent
69502c44fe
commit
46b0745412
@ -43,9 +43,6 @@
|
||||
- ignore: {name: "Fuse concatMap/map"}
|
||||
- ignore: {name: "Redundant where"}
|
||||
- ignore: {name: "Use concatMap"}
|
||||
- ignore: {name: "Use second"}
|
||||
- ignore: {name: "Use fromRight"}
|
||||
- ignore: {name: "Use fromLeft"}
|
||||
- ignore: {name: "Redundant bang pattern"}
|
||||
- ignore: {name: "Use zipWith"}
|
||||
- ignore: {name: "Replace case with maybe"}
|
||||
|
||||
@ -59,6 +59,7 @@ where
|
||||
|
||||
import Control.Applicative (Const(..), (<|>))
|
||||
import Control.Monad ((<=<), join)
|
||||
import Data.Either (fromRight)
|
||||
import Data.Either.Extra (eitherToMaybe)
|
||||
import Data.Functor.Identity (Identity(..))
|
||||
import Data.List.Extra (nubSort)
|
||||
@ -699,7 +700,7 @@ instance Reportable (Const r) e where
|
||||
report _ (Const x) = Const x
|
||||
|
||||
instance Reportable Identity e where
|
||||
report a (Identity i) = Identity $ either (const a) id i
|
||||
report a (Identity i) = Identity $ fromRight a i
|
||||
|
||||
instance Reportable Maybe e where
|
||||
report _ = join . fmap eitherToMaybe
|
||||
|
||||
@ -8,6 +8,7 @@ where
|
||||
|
||||
import Brick.Widgets.Edit
|
||||
import Data.Foldable (asum)
|
||||
import Data.Either (fromRight)
|
||||
import Data.List ((\\), foldl', sort)
|
||||
import Data.Semigroup (Max(..))
|
||||
import qualified Data.Text as T
|
||||
@ -246,7 +247,7 @@ setFilter :: String -> UIState -> UIState
|
||||
setFilter s ui@UIState{aopts=uopts@UIOpts{cliopts_=copts@CliOpts{reportspec_=rspec}}} =
|
||||
ui{aopts=uopts{cliopts_=copts{reportspec_=update rspec}}}
|
||||
where
|
||||
update = either (const rspec) id . updateReportSpecWith (\ropts -> ropts{querystring_=querystring}) -- XXX silently ignores an error
|
||||
update = fromRight rspec . updateReportSpecWith (\ropts -> ropts{querystring_=querystring}) -- XXX silently ignores an error
|
||||
querystring = words'' prefixes $ T.pack s
|
||||
|
||||
-- | Reset some filters & toggles.
|
||||
|
||||
@ -35,6 +35,7 @@ import Brick.Widgets.Dialog
|
||||
import Brick.Widgets.Edit
|
||||
import Brick.Widgets.List (List, listSelectedL, listNameL, listItemHeightL)
|
||||
import Control.Monad.IO.Class
|
||||
import Data.Bifunctor (second)
|
||||
import Data.List
|
||||
import qualified Data.Text as T
|
||||
import Data.Time (Day, addDays)
|
||||
@ -192,7 +193,7 @@ borderPeriodStr _ PeriodAll = str ""
|
||||
borderPeriodStr preposition p = str (" "++preposition++" ") <+> withAttr ("border" <> "query") (str . T.unpack $ showPeriod p)
|
||||
|
||||
borderKeysStr :: [(String,String)] -> Widget Name
|
||||
borderKeysStr = borderKeysStr' . map (\(a,b) -> (a, str b))
|
||||
borderKeysStr = borderKeysStr' . map (second str)
|
||||
|
||||
borderKeysStr' :: [(String,Widget Name)] -> Widget Name
|
||||
borderKeysStr' keydescs =
|
||||
|
||||
@ -17,6 +17,8 @@ import Control.Monad
|
||||
import System.Exit
|
||||
import Data.Time.Calendar
|
||||
import Text.Printf
|
||||
import Data.Bifunctor (second)
|
||||
import Data.Either (fromLeft, fromRight)
|
||||
import Data.Function (on)
|
||||
import Data.List
|
||||
import Numeric.RootFinding
|
||||
@ -172,7 +174,7 @@ timeWeightedReturn showCashFlow prettyTables investmentsQuery trans mixedAmountV
|
||||
$ map (\date_cash -> let (dates, cash) = unzip date_cash in (head dates, Right (maSum cash)))
|
||||
$ groupBy ((==) `on` fst)
|
||||
$ sortOn fst
|
||||
$ map (\(d,a) -> (d, maNegate a))
|
||||
$ map (second maNegate)
|
||||
$ cashFlow
|
||||
|
||||
let units =
|
||||
@ -205,8 +207,8 @@ timeWeightedReturn showCashFlow prettyTables investmentsQuery trans mixedAmountV
|
||||
when showCashFlow $ do
|
||||
printf "\nTWR cash flow for %s - %s\n" (showDate spanBegin) (showDate (addDays (-1) spanEnd))
|
||||
let (dates', amounts) = unzip changes
|
||||
cashflows' = map (either (const nullmixedamt) id) amounts
|
||||
pnls = map (either id (const nullmixedamt)) amounts
|
||||
cashflows' = map (fromRight nullmixedamt) amounts
|
||||
pnls = map (fromLeft nullmixedamt) amounts
|
||||
(valuesOnDate,unitsBoughtOrSold', unitPrices', unitBalances') = unzip4 units
|
||||
add x lst = if valueBefore/=0 then x:lst else lst
|
||||
dates = add spanBegin dates'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user