{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}moduleUHC.Util.NmwhereimportData.MaybeimportData.CharimportData.ListimportUHC.Util.PrettyimportUHC.Util.FPath(FPATH(mkFPath))importUHC.Util.Utils--------------------------------------------------------------------------- Names (for use in Shuffle, Ruler)-------------------------------------------------------------------------dataNm's=NmEmp|Nm{nmStr::s}|NmSel{nmNm::Nm's,nmMbSel::Maybes}|NmQual{nmNm::Nm's,nmQual::s}deriving(Eq,Ord)typeNm=Nm'StringnmSelSep,nmQualSep::StringnmSelSep="."nmQualSep="_"nmBase'::Nm->StringnmBase'(NmSeln_)=nmBase'nnmBase'(Nms)=snmBase'NmEmp=""nmBase::Nm->NmnmBase=Nm.nmBase'nmSetSuff::Nm->String->NmnmSetSuffns=NmSel(nmBasen)(Justs)nmSetBase::Nm->String->NmnmSetBasens=nmFromMbL(Justs:nL)where(_:nL)=nmToMbLnnmSetSel::Nm's->s->Nm'snmSetSelns=NmSeln(Justs)nmSel::Nm->StringnmSel=maybe""id.nmMbSelnmInit::Nm->NmnmInit(NmSeln_)=nnmInitn=nnmToMbL::Nm's->[Maybes]nmToMbL=reverse.nswherens(NmSelns)=s:nsnns(Nms)=[Justs]nsNmEmp=[]nmToL::Nm->[String]nmToL=map(maybe""id).nmToMbLnmFromMbL::[Maybes]->Nm'snmFromMbL=n.reversewheren[Justs]=Nmsn(s:ss)=NmSel(nss)sn[]=NmEmpnmFromL::[s]->Nm'snmFromL=nmFromMbL.mapJustnmApd::Nm's->Nm's->Nm'snmApdn1n2=nmFromMbL(l1++l2)wherel1=nmToMbLn1l2=nmToMbLn2nmApdL::[Nm's]->Nm'snmApdL=nmFromMbL.concat.mapnmToMbLnmStrApd::Nm->Nm->NmnmStrApdn1n2=Nm(s1++s2)wheres1=shown1s2=shown2nmCapitalize::Nm->NmnmCapitalizen=casenmToMbLnof(Justs:ns)->nmFromMbL(Just(strCapitalizes):ns)_->nnmDashed::Nm->NmnmDashed=Nm.map(\c->ifisAlphaNumcthencelse'-').shownmFlatten::Nm->NmnmFlatten=Nm.shownmShow'::String->Nm->StringnmShow'sep=concat.interspersesep.nmToLnmShowAG::Nm->StringnmShowAG=nmShow'"_"instanceShowNmwhereshow=nmShow'nmSelSepinstancePPNmwherepp=ppListSep""""nmSelSep.nmToLinstanceFunctorNm'wherefmapfNmEmp=NmEmpfmapf(Nms)=Nm(fs)fmapf(NmSelnms)=NmSel(fmapfn)(fmapfms)fmapf(NmQualns)=NmQual(fmapfn)(fs)--------------------------------------------------------------------------- Make name of something-------------------------------------------------------------------------classNMawheremkNm::a->NminstanceNMNmwheremkNm=idinstanceNMStringwheremkNms=nmFromL[s]instanceNMIntwheremkNm=mkNm.show--------------------------------------------------------------------------- Make FPath of Nm-------------------------------------------------------------------------instanceFPATHNmwheremkFPath=mkFPath.show