moduleDebian.Relation.Commonwhere-- Standard GHC ModulesimportData.ListimportText.ParserCombinators.Parsec-- Local ModulesimportDebian.Version-- Datatype for relationstypePkgName=StringtypeRelations=AndRelationtypeAndRelation=[OrRelation]typeOrRelation=[Relation]dataRelation=RelPkgName(MaybeVersionReq)(MaybeArchitectureReq)derivingEqclassParseRelationsawhere-- |'parseRelations' parse a debian relation (i.e. the value of a-- Depends field). Return a parsec error or a value of type-- 'Relations'parseRelations::a->EitherParseErrorRelationsinstanceShowRelationwhereshow(Relnameverarch)=name++maybe""showver++maybe""showarchinstanceOrdRelationwherecompare(RelpkgName1mVerReq1_mArch1)(RelpkgName2mVerReq2_mArch2)=casecomparepkgName1pkgName2ofLT->LTGT->GTEQ->comparemVerReq1mVerReq2dataArchitectureReq=ArchOnly[String]|ArchExcept[String]derivingEqinstanceShowArchitectureReqwhereshow(ArchOnlyarch)=" ["++intercalate" "arch++"]"show(ArchExceptarch)=" [!"++intercalate" !"arch++"]"dataVersionReq=SLTDebianVersion|LTEDebianVersion|EEQDebianVersion|GREDebianVersion|SGRDebianVersionderivingEqinstanceShowVersionReqwhereshow(SLTv)=" (<< "++showv++")"show(LTEv)=" (<= "++showv++")"show(EEQv)=" (= "++showv++")"show(GREv)=" (>= "++showv++")"show(SGRv)=" (>> "++showv++")"-- |@FIXME:@ This instance is currently incomplete and only handles the case-- where two version requirements are equal.instanceOrdVersionReqwherecomparer1r2=ifr1==r2thenEQelsecase(r1,r2)of(EEQv1,EEQv2)->comparev1v2(a,b)->error$"Ord VersionReq does not handle ("++showa++", "++showb++")"-- |Check if a version number satisfies a version requirement.checkVersionReq::MaybeVersionReq->MaybeDebianVersion->BoolcheckVersionReqNothing_=TruecheckVersionReq_Nothing=FalsecheckVersionReq(Just(SLTv1))(Justv2)=v2<v1checkVersionReq(Just(LTEv1))(Justv2)=v2<=v1checkVersionReq(Just(EEQv1))(Justv2)=v2==v1checkVersionReq(Just(GREv1))(Justv2)=v2>=v1checkVersionReq(Just(SGRv1))(Justv2)=v2>v1