{-# LANGUAGE OverloadedStrings #-}-- | Cabin color schemes---- Each element of a Cabin report identifies what it is--a debit on an-- even line, a credit on an odd line, etc. The user can have several-- color schemes; the scheme contains color assignments for 8 and 256-- color terminals. This allows the use of different schemes for light-- and dark terminals or for any other reason.modulePenny.Cabin.SchemewhereimportqualifiedPenny.Cabin.MetaasMimportqualifiedPenny.LincolnasLimportqualifiedData.TextasXimportqualifiedSystem.Console.RainbowasRdataLabel=Debit|Credit|Zero|Otherderiving(Eq,Ord,Show)dataEvenOdd=Even|Oddderiving(Eq,Ord,Show)dataLabelsa=Labels{debit::a,credit::a,zero::a,other::a}derivingShowgetLabelValue::Label->Labelsa->agetLabelValuells=caselofDebit->debitlsCredit->creditlsZero->zerolsOther->otherlsdataEvenAndOdda=EvenAndOdd{eoEven::a,eoOdd::a}derivingShowtypeChangers=Labels(EvenAndOdd(R.Chunk->R.Chunk))dataScheme=Scheme{name::String-- ^ The name of this scheme. How it will be identified on the-- command line.,description::String-- ^ A brief (one-line) description of what this scheme is, such-- as @for dark background terminals@,changers::Changers}derivingShowgetEvenOdd::EvenOdd->EvenAndOdda->agetEvenOddeoeao=caseeoofEven->eoEveneaoOdd->eoOddeaogetEvenOddLabelValue::Label->EvenOdd->Labels(EvenAndOdda)->agetEvenOddLabelValueleols=getEvenOddeo(getLabelValuells)fromVisibleNum::M.VisibleNum->EvenOddfromVisibleNumvn=lets=M.unVisibleNumvninifeven.L.forward$sthenEvenelseOdddcToLbl::L.DrCr->LabeldcToLblL.Debit=DebitdcToLblL.Credit=CreditbottomLineToDrCr::L.BottomLine->EvenOdd->Changers->R.ChunkbottomLineToDrCrbleochgrs=mdcwhere(c,md)=caseblofL.Zero->(R.plain"--",getEvenOddLabelValueZeroeochgrs)L.NonZero(L.ColumnclmDrCr_)->caseclmDrCrofL.Debit->(R.plain"<",getEvenOddLabelValueDebiteochgrs)L.Credit->(R.plain">",getEvenOddLabelValueCrediteochgrs)balancesToCmdtys::Changers->EvenOdd->[(L.Commodity,L.BottomLine)]->[R.Chunk]balancesToCmdtyschgrseols=ifnulllsthen[getEvenOddLabelValueZeroeochgrs$R.plain"--"]elsemap(bottomLineToCmdtychgrseo)lsbottomLineToCmdty::Changers->EvenOdd->(L.Commodity,L.BottomLine)->R.ChunkbottomLineToCmdtychgrseo(cy,bl)=mdcwherec=R.plain.L.unCommodity$cylbl=caseblofL.Zero->ZeroL.NonZero(L.ColumnclmDrCr_)->dcToLblclmDrCrmd=getEvenOddLabelValuelbleochgrsbalanceToQtys::Changers->(L.Commodity->L.Qty->X.Text)->EvenOdd->[(L.Commodity,L.BottomLine)]->[R.Chunk]balanceToQtyschgrsgetTxteols=ifnulllsthenletmd=getEvenOddLabelValueZeroeochgrsin[md(R.plain"--")]elsemap(bottomLineToQtychgrsgetTxteo)lsbottomLineToQty::Changers->(L.Commodity->L.Qty->X.Text)->EvenOdd->(L.Commodity,L.BottomLine)->R.ChunkbottomLineToQtychgrsgetTxteo(cy,bl)=md(R.plaint)where(lbl,t)=caseblofL.Zero->(Zero,X.pack"--")L.NonZero(L.ColumnclmDrCrqt)->(dcToLblclmDrCr,getTxtcyqt)md=getEvenOddLabelValuelbleochgrs