-- | The core module of the Data.Derive system. This module contains-- the data types used for communication between the extractors and-- the derivors.moduleLanguage.Haskell.TH.DatawhereimportData.CharimportData.GenericsimportLanguage.Haskell.TH.SyntaximportLanguage.Haskell.TH.Compat-- must be one of DataD or NewtypeDtypeDataDef=DectypeCtorDef=CondataName::DataDef->StringdataName(DataD_name___)=unqualifiedNamenamedataName(NewtypeD_name___)=unqualifiedNamenamequalifiedDataName::DataDef->NamequalifiedDataName(DataD_name___)=namequalifiedDataName(NewtypeD_name___)=namedataArity::DataDef->IntdataArity(DataD__xs__)=lengthxsdataArity(NewtypeD__xs__)=lengthxsdataArgs::DataDef->[Name]dataArgs=dataDefinitionTypeArgsdataCtors::DataDef->[CtorDef]dataCtors(DataD___xs_)=xsdataCtors(NewtypeD___x_)=[x]ctorName::CtorDef->StringctorName(NormalCname_)=unqualifiedNamenamectorName(RecCname_)=unqualifiedNamenamectorName(InfixC_name_)=unqualifiedNamenamectorName(ForallC__c)=ctorNamecqualifiedCtorName::CtorDef->NamequalifiedCtorName(NormalCname_)=namequalifiedCtorName(RecCname_)=namequalifiedCtorName(InfixC_name_)=namequalifiedCtorName(ForallC__c)=qualifiedCtorNamecctorArity::CtorDef->IntctorArity(NormalC_xs)=lengthxsctorArity(RecC_xs)=lengthxsctorArity(InfixC___)=2ctorArity(ForallC__c)=ctorAritycctorStrictTypes::CtorDef->[StrictType]ctorStrictTypes(NormalC_xs)=xsctorStrictTypes(RecC_xs)=[(b,c)|(a,b,c)<-xs]ctorStrictTypes(InfixCx_y)=[x,y]ctorStrictTypes(ForallC__c)=ctorStrictTypescctorTypes::CtorDef->[Type]ctorTypes=mapsnd.ctorStrictTypesctorFields::CtorDef->[String]ctorFields(RecCnamevarStrictType)=[unqualifiedNamename|(name,strict,typ)<-varStrictType]ctorFields_=[]-- normalisation-- make sure you deal with "GHC.Base.."dropModule::String->StringdropModulexs=casereversexsof('.':xs)->takeWhile(=='.')xsxs->reverse$takeWhile(/='.')xs-- i_123432 -> idropNumber::String->StringdropNumberxs=ifallisDigitathenreverse(tailb)elsexswhere(a,b)=break(=='_')$reversexsnormData::DataDef->DataDefnormData=everywhere(mkTnormType)wherenormType::Type->TypenormType(ConTx)|showx=="[]"=ListTnormTypex=xunqualifiedName::Name->StringunqualifiedName=dropModule.show-- convert AppT chains back to a proper listtypeApp::Type->(Type,[Type])typeApp(AppTlr)=(a,b++[r])where(a,b)=typeAppltypeAppt=(t,[])eqConT::String->Type->BooleqConTname(ConTx)=name==showxeqConT__=FalseisTupleT::Type->BoolisTupleT(TupleT_)=TrueisTupleT(ConTx)=headsx=='('&&lastsx==')'&&all(==',')(take(lengthsx-2)(tailsx))wheresx=nameBasexisTupleT_=False