{-
Copyright (C) 2009 Andrejs Sisojevs <andrejs.sisojevs@nextmail.ru>
All rights reserved.
For license and copyright information, see the file COPYRIGHT
-}----------------------------------------------------------------------------------------------------------------------------------------------------{-# LANGUAGE DeriveDataTypeable #-}-- | A module around comlex function '_readPCLTCatalog'.moduleText.PCLT.MakeCatalogwhereimportqualifiedData.ByteString.Lazy.UTF8.UnifiedasLazy(ByteString)importqualifiedData.ByteString.Lazy.UTF8.UnifiedasBhiding(ByteString)importData.ListimportqualifiedData.MapasMimportData.Map(Map,(!))importData.MaybeimportData.MyHelpersimportData.TypeableimportText.PCLT.CatalogimportText.PCLT.CommonTypesimportText.PCLT.ConfigimportText.PCLT.SDLimportText.PCLT.TemplatetypeParsed_DidWe=Bool-- | Error type for '_readPCLTCatalog'.---- Descriptios for some value constructors:---- * 'DefaultLngTplComponentsParamsSetsDiffersFromOnesOfNondefault_RPCSCE':-- For more information about this error see-- 'Text.PCLT.Config.StrictOrient_ofParamsAndCmpsts_onDfltLngTplsSets'---- * 'DifferentSDLs_RPCSCE':-- This may occur in case when some 'PCLT_RawCatalogData' is-- added to a nonempty 'PCLT_Catalog', and same templates in both-- places has different SDL requirements.---- * 'TplUniquenessViol_RPCSCE':-- This may occur in case when some 'PCLT_RawCatalogData' is-- added to a nonempty 'PCLT_Catalog', and there isan intersection-- between their \{(Template ID, Language)\} sets.---- * 'SDL_ToCompositeLinkRefsToNonexistent_RPCSCE':-- SDL requirement specification-- ('Text.PCLT.Template.pcltRequiredSDL') for a template is of type-- 'Text.PCLT.Template.PCLT_SDL_ToTemplateLink' and references to-- a template which is not persistant in catalog or raw input data.dataReadPCSCatalogError=CompositionCycle_RPCSCECompositionCycle_PCLTE|RequiredCompositeIsMissing_RPCSCERequiredByRequirerCompositeIsMissing_PCLTE|RequiredCompositeIsUnparsable_RPCSCERequirerCompositeKeyRequiredCompositeKey|ParseFailedForDefaultLng_RPCSCEPCLT_CompositeKeyParsed_DidWe[PCLT_ParserLowLevelFailure]|TplDefaultLngIsMissing_RPCSCETplDefaultLngIsMissing_PCLTE|ParseFailedForNondefaultLng_RPCSCEPCLT_CompositeKeyParsed_DidWeLanguageName[PCLT_ParserLowLevelFailure]|DefaultLngTplComponentsParamsSetsDiffersFromOnesOfNondefault_RPCSCEDefaultLngTplComponentsParamsSetsDiffersFromOnesOfNondefault_PCLTE|DifferentSDLs_RPCSCEDifferentSDLs_PCLTE|TplUniquenessViol_RPCSCETplUniquenessViol_PCLTE|SDL_ToCompositeLinkRefsToNonexistent_RPCSCERequirerCompositeKeyRequiredCompositeKey|DRL_NormalizationError_RPCSCEDRL_NormalizationErrorderiving(Show,Typeable)-- | Wrapper around '_readPCLTCatalog'. To be used when starting with an empty catalog.readPCLTCatalog::PCLT_InnerConfig->PCLT_CatalogID->PCLT_RawCatalogData->(PCLT_Catalog,[ErrorWithPCSCatalogReadPCSCatalogError])readPCLTCatalogpcsc_configcat_idraw_input=letinit_cat=PCLT_Catalog{pcltcCatalogID=cat_id,pcltcCatalogMap=M.empty,pcltcInnerConfig=pcsc_config}in_readPCLTCatalog(init_cat,[])raw_input-- | Take a bunch of raw templates, parse them into normal templates and add-- them to a catalog._readPCLTCatalog::(PCLT_Catalog,[ReadPCSCatalogError])->PCLT_RawCatalogData->(PCLT_Catalog,[ErrorWithPCSCatalogReadPCSCatalogError])_readPCLTCatalog(init_cat,init_errs)(PCLT_RawCatalogDatamessages_raws_map1)=-- traceShowPaged 5 ("**", M.filterWithKey (\ k _ -> k == "HW" || k == "E_PCLT_P2TE" ) messages_raws_map1) $let(messages_raws_map2,pclt_catalog_map1,err_msgs1)=filterPrepareRawInputData(pcltcCatalogMapinit_cat,init_errs)messages_raws_map1(pclt_catalog_map2,err_msgs2)=processToPCLT_Catalog(pclt_catalog_map1,err_msgs1)messages_raws_map2(pclt_catalog_map3,err_msgs3)=normalizeReferentialSDLspclt_catalog_map2err_msgs=map(ErrorWithPCSCatalogcat_id)(err_msgs2++mapDRL_NormalizationError_RPCSCEerr_msgs3)in(init_cat{pcltcCatalogMap=pclt_catalog_map3},err_msgs)wherecat_id=pcltcCatalogIDinit_catpcsc_config=pcltcInnerConfiginit_catdefault_lng=pcsDefaultLanguagepcsc_configso=pcsStrictOrient_ofParamsAndCmpsts_onDfltLngTplsSetspcsc_configerr6msg_idbuf=CompositionCycle_RPCSCE$CompositionCycle_PCLTEmsg_idbuferr7msg_idsubcomp_id=RequiredCompositeIsMissing_RPCSCE$RequiredByRequirerCompositeIsMissing_PCLTEmsg_id$RequiredCompositeIsMissing_PCLTEsubcomp_iderr8msg_idsubcomp_id=RequiredCompositeIsUnparsable_RPCSCEmsg_idsubcomp_iderr12msg_idpdwerrs_list=ParseFailedForDefaultLng_RPCSCEmsg_idpdwerrs_listerr13msg_id=TplDefaultLngIsMissing_RPCSCE$TplDefaultLngIsMissing_PCLTEmsg_iderr14msg_idpdwlngerrs_list=ParseFailedForNondefaultLng_RPCSCEmsg_idpdwlngerrs_listerr15msg_idlng=DefaultLngTplComponentsParamsSetsDiffersFromOnesOfNondefault_RPCSCE$DefaultLngTplComponentsParamsSetsDiffersFromOnesOfNondefault_PCLTEmsg_idlngerr16msg_id(msdl,asdl)=DifferentSDLs_RPCSCE$DifferentSDLs_PCLTEmsg_id(msdl,asdl)err17msg_idlng_list=TplUniquenessViol_RPCSCE$TplUniquenessViol_PCLTEmsg_idlng_listerr20msg_idsubcomp_id=SDL_ToCompositeLinkRefsToNonexistent_RPCSCEmsg_idsubcomp_id-----------------------------------------------------------filterPrepareRawInputData::(PCLT_CatalogMap,[ReadPCSCatalogError])->MapPCLT_CompositeKey(MapLanguageNameLazy.ByteString,PCLT_RequiredShowDetalizationLevel)->(MapPCLT_CompositeKey(MapLanguageName(EitherLocalizedTemplateLazy.ByteString),PCLT_RequiredShowDetalizationLevel),MapPCLT_CompositeKeyLocalizableTemplate-- PCLT_CatalogMap,[ReadPCSCatalogError])filterPrepareRawInputData(processed_msgs_accum_map1,errs_accum)raw_msgs_src_map=letmakeInputEntry::PCLT_ID->(MaybeLocalizableTemplate,Maybe(MapLanguageNameLazy.ByteString,PCLT_RequiredShowDetalizationLevel))->(MapLanguageName(EitherLocalizedTemplateLazy.ByteString),PCLT_RequiredShowDetalizationLevel,[ReadPCSCatalogError])makeInputEntryk(mb_pclt,mb_mapByLng)=letunionWithKey_3_ERROR=error"Severe internal error (in _readPCLTCatalog) unionWithKey_3(4) can't give (Nothing, Nothing) to the unifier !!!"incase(mb_pclt,mb_mapByLng)of(Nothing,Nothing)->unionWithKey_3_ERROR(Nothing,Just(mapByLng,sdl))->(M.mapRightmapByLng,sdl,[])-- (Just pclt, Nothing) case processed by the callerof makeInputEntry(Justpclt,Just(mapByLng,sdl2))->letsdl1=pcltRequiredSDLpclt(result_mapByLng,uniqviol_lng_list)=unionWithKey_3(\lng(mb_ldt,mb_rawInput)->-- unifierFcase(mb_ldt,mb_rawInput)of(Nothing,Nothing)->unionWithKey_3_ERROR(Nothing,JustrawInput)->(RightrawInput,[])(Justldt,Nothing)->(Leftldt,[])(Justldt,JustrawInput)->(Leftldt,[lng]))(++)-- sideResultAccumF[](pcltLocalizationsMappclt)mapByLngerrs_add=(casesdl1==sdl2of{True->[];False->[err16k(sdl1,sdl2)]})++(caseuniqviol_lng_listof{[]->[];l->[err17kl]})in(result_mapByLng,sdl1,errs_add)(raw_msgs_src_map2,(processed_msgs_accum_map2,errs_accum2))=unionWithKey_4(\k(mb_pclt,mb_mapByLng)->case(mb_pclt,mb_mapByLng)of(Justpclt,Nothing)->(Nothing,(M.singletonkpclt,[]))_->let(result_map,sdl,errs_add)=makeInputEntryk(mb_pclt,mb_mapByLng)in(Just(result_map,sdl),(M.empty,errs_add)))(apFor2ple(M.union,(++)))-- sideResultAccumF(M.empty,errs_accum)processed_msgs_accum_map1raw_msgs_src_mapin(raw_msgs_src_map2,processed_msgs_accum_map2,errs_accum2)-----------------------------------------------------------processToPCLT_Catalog::(PCLT_CatalogMap,[ReadPCSCatalogError])->(MapPCLT_CompositeKey(MapLanguageName(EitherLocalizedTemplateLazy.ByteString),PCLT_RequiredShowDetalizationLevel))->(PCLT_CatalogMap,[ReadPCSCatalogError])processToPCLT_Catalog(processed_msgs_accum_map,errs_accum)halfRaw_input=caseM.nullhalfRaw_inputofTrue->(processed_msgs_accum_map,errs_accum)False->let((k,(msg_raw_lng_map,sdl)),new_raw_msgs_src_map)=M.deleteFindMinhalfRaw_inputinuncurryprocessToPCLT_Catalog(processToPCLT_Catalog_Unit(processed_msgs_accum_map,errs_accum)(k,msg_raw_lng_map,sdl)[]new_raw_msgs_src_map)-----------------------------------------------------------parseMsgTemplates::PCLT_CompositeKey->MapLanguageName(EitherLocalizedTemplateLazy.ByteString)->([ReadPCSCatalogError],MapLanguageName(EitherLocalizedTemplate(LngTpl_AbstractedString,[PCLT_CompositeKey])))parseMsgTemplateskraw_msgs_by_lngs_map=-- traceCond (k == "HW" || k == "E_PCLT_P2TE") 5 ("**", raw_msgs_by_lngs_map) $casetakeFromMapdefault_lngraw_msgs_by_lngs_mapof(Nothing,_)->([err13k],M.empty)(Justdefault_ldt_or_raw,rest_raw_msgs_by_lngs_map)->let(mb_default_ldt_or_freshParse,errs_list1,default_list_of_composites,default_list_of_params)=casedefault_ldt_or_rawofLeftldt->(Just$Leftldt,[],M.keys$ldtSubcompositesMapldt,listOfParams$ldtAbstractedStringldt)Rightdefault_raw_msg->casedoTheParsepcsc_configdefault_raw_msgof(errs_list1,Nothing)->(Nothing,[err12kFalseerrs_list1],[],[])(errs_list1,Justdefault_freshParse@(dflt_str_struct,dflt_list_of_composites))->(Just$Rightdefault_freshParse,casenullerrs_list1of{True->[];False->[err12kTrueerrs_list1]},dflt_list_of_composites,listOfParamsdflt_str_struct)incasemb_default_ldt_or_freshParseofNothing->(errs_list1,M.empty)Justdefault_ldt_or_freshParse->foldr(\(lng,ldt_or_raw)(errs_accum,parseds_accum_map)->caseldt_or_rawofLeftldt->(errs_accum,M.insertlng(Leftldt)parseds_accum_map)Rightunparsed_tpl->casedoTheParsepcsc_configunparsed_tplof(errs_list2,Nothing)->(err14kFalselngerrs_list2:errs_accum,parseds_accum_map)(errs_list2,JustfreshParse@(str_struct,list_of_composites))->letorients_doesit=_compareStrictOrientationOnDefaultkso(default_list_of_composites,default_list_of_params)(list_of_composites,listOfParamsstr_struct)incaseorients_doesitofFalse->(err15klng:errs_accum,parseds_accum_map)True->(casenullerrs_list2ofFalse->err14kTruelngerrs_list2:errs_accumTrue->errs_accum,M.insertlng(RightfreshParse)parseds_accum_map))(errs_list1,M.singletondefault_lngdefault_ldt_or_freshParse)(M.toListrest_raw_msgs_by_lngs_map)-----------------------------------------------------------processToPCLT_Catalog_Unit::(PCLT_CatalogMap,[ReadPCSCatalogError])->(PCLT_CompositeKey,MapLanguageName(EitherLocalizedTemplateLazy.ByteString),PCLT_RequiredShowDetalizationLevel)->[PCLT_CompositeKey]->(MapPCLT_CompositeKey(MapLanguageName(EitherLocalizedTemplateLazy.ByteString),PCLT_RequiredShowDetalizationLevel))->((PCLT_CatalogMap,[ReadPCSCatalogError]),(MapPCLT_CompositeKey(MapLanguageName(EitherLocalizedTemplateLazy.ByteString),PCLT_RequiredShowDetalizationLevel)))processToPCLT_Catalog_Unit(processed_msgs_accum_map,errs_accum)(k,msg_raw_or_ldt_mapByLng,sdl)superprocessed_bufferraw_msgs_src_map=letreturnWithErrorerr_str=((processed_msgs_accum_map,err_str:errs_accum),raw_msgs_src_map)incasek`elem`superprocessed_bufferofTrue->returnWithError(err6ksuperprocessed_buffer)False->let(errs_list,ldt_or_froshParseds_map)=parseMsgTemplateskmsg_raw_or_ldt_mapByLng(ldt_mapByLng1,absStr_mapByLng)=partition_2isLeft(fromLeft,fromRight)ldt_or_froshParseds_map-- agree... not a best styleerrs_accum2=errs_accum++errs_list(ldt_mapByLng2,(processed_msgs_accum_map2,raw_msgs_src_map2),errs_accum6)=foldl(\(ldt_mapByLng_accum,(_processed_msgs_accum_map1,_raw_msgs_src_map1),errs_accum3)(lng,(msg_chunks_struct,list_of_composites_keys))->let(msg_composites,(_processed_msgs_accum_map2,_raw_msgs_src_map2),errs_accum4)=foldlgatherCatalogUnitSubcomposites(M.empty,(_processed_msgs_accum_map1,_raw_msgs_src_map1),errs_accum3)list_of_composites_keysldt=LocalizedTemplate{ldtAbstractedString=msg_chunks_struct,ldtSubcompositesMap=msg_composites}in(M.insertlngldtldt_mapByLng_accum,(_processed_msgs_accum_map2,_raw_msgs_src_map2),errs_accum4))(ldt_mapByLng1,(processed_msgs_accum_map,raw_msgs_src_map),errs_accum2)(M.toListabsStr_mapByLng)pclt=LocalizableTemplate{pcltRequiredSDL=sdl,pcltLocalizationsMap=ldt_mapByLng2}in((M.insertkpcltprocessed_msgs_accum_map2,errs_accum6),raw_msgs_src_map2)-----------------------------------------------------------wheregatherCatalogUnitSubcomposites::(LngTpl_SubCompositesMap,(MapPCLT_IDLocalizableTemplate,MapPCLT_CompositeKey(MapLanguageName(EitherLocalizedTemplateLazy.ByteString),PCLT_RequiredShowDetalizationLevel)),[ReadPCSCatalogError])->PCLT_CompositeKey->(LngTpl_SubCompositesMap,(MapPCLT_IDLocalizableTemplate,MapPCLT_CompositeKey(MapLanguageName(EitherLocalizedTemplateLazy.ByteString),PCLT_RequiredShowDetalizationLevel)),[ReadPCSCatalogError])gatherCatalogUnitSubcomposites(msg_composites_accum,(processed_msgs_accum_map,raw_msgs_src_map),errs_accum)composite_key=letreturnWithErrorstr=(msg_composites_accum,(processed_msgs_accum_map,raw_msgs_src_map),str:errs_accum)incaseM.lookupcomposite_keyprocessed_msgs_accum_mapofJustpcs->(M.insertcomposite_keypcsmsg_composites_accum,(processed_msgs_accum_map,raw_msgs_src_map),errs_accum)Nothing->casetakeFromMapcomposite_keyraw_msgs_src_mapof(Nothing,_)->casek==composite_keyofFalse->casecomposite_key`elem`superprocessed_bufferofFalse->returnWithError(err7kcomposite_key)True->returnWithError(err6composite_key(composite_key:k:superprocessed_buffer))True->returnWithError(err6k[k])(Just(raw_subcomp_msgs_map_by_lng,sub_sdl),new_raw_msgs_src_map)->let((new_processed_msgs_accum_map,new_errs_accum),new_new_raw_msgs_src_map)=processToPCLT_Catalog_Unit(processed_msgs_accum_map,errs_accum)(composite_key,raw_subcomp_msgs_map_by_lng,sub_sdl)(k:superprocessed_buffer)new_raw_msgs_src_mapreturnWithError3err=(msg_composites_accum,(new_processed_msgs_accum_map,new_new_raw_msgs_src_map),err:new_errs_accum)incaseM.lookupcomposite_keynew_processed_msgs_accum_mapofNothing->returnWithError3(err8kcomposite_key)Justpcs->(M.insertcomposite_keypcsmsg_composites_accum,(new_processed_msgs_accum_map,new_new_raw_msgs_src_map),new_errs_accum)---------------------------------------------------------------------- | Error type for 'normalizeReferentialSDLs'.dataDRL_NormalizationError=SDL_ToCompositeLinksCycle_DRLNE[PCLT_CompositeKey]|SDL_DetFail_ToCompositeLinkRefsToNonexistent_DRLNERequirerCompositeKeyRequiredCompositeKeyderiving(Show,Typeable)-- | Under \"Referential SDLs normalization\" here is understood the following.-- Now consider paths like:---- @ Tpl_1.'pcltRequiredSDL' -> Tpl_2.'pcltRequiredSDL'@---- which means 'pcltRequiredSDL' of @Tpl_1@ is specified (using-- 'PCLT_SDL_ToTemplateLink') to be the same as for @Tpl_2@. Here we can-- reduce the 'PCLT_SDL_ToTemplateLink' of @Tpl_1@ by assinging instead of it-- @Tpl_2.@'pcltRequiredSDL' value. Data consistency is respected. We win in-- speed of @Tpl_1.@'pcltRequiredSDL' determination. The negative side of this,-- is that we can't change @Tpl_2.@'pcltRequiredSDL' anymore without spoiling-- data consistency. That's another reason why a PCLT catalog is so hard to-- modify. Perhaps the problem will be solved in future versions of PCLT.---- So this function reduces all 'PCLT_SDL_ToTemplateLink's in a given-- 'PCLT_CatalogMap', BUT, only where they lead to 'PCLT_SDL's or-- to other 'PCLT_SDL_ToTemplateLink's (which recursively gets considered-- to be reduced), not when it leads to 'PCLT_SDL_ToParamCompositeLink'-- or 'PCLT_SDL_Errornous'.normalizeReferentialSDLs::PCLT_CatalogMap->(PCLT_CatalogMap,[DRL_NormalizationError])normalizeReferentialSDLspclt_catalog_map=leterr21buf=SDL_ToCompositeLinksCycle_DRLNEbuferr23rer_idred_id=SDL_DetFail_ToCompositeLinkRefsToNonexistent_DRLNErer_idred_iddeterminePCLT_SDL::(PCLT_ID,LocalizableTemplate)->(PCLT_CatalogMap,PCLT_CatalogMap,[DRL_NormalizationError],[PCLT_CompositeKey])->(PCLT_CatalogMap,PCLT_CatalogMap,[DRL_NormalizationError],PCLT_RequiredShowDetalizationLevel)determinePCLT_SDL(pclt_id,pclt)(processed_cat_accum,unprocessed_cat_map,err_msg_accum,useds_buf)=casepclt_id`elem`useds_bufofTrue->(M.insertpclt_idpcltprocessed_cat_accum,unprocessed_cat_map,err_msg_accum++[err21(pclt_id:useds_buf)],pcltRequiredSDLpclt)False->casepcltRequiredSDLpcltofPCLT_SDL_ToTemplateLinkref_pclt_id->caseM.lookupref_pclt_idprocessed_cat_accumofJustrefed_pclt->letsdl=pcltRequiredSDLrefed_pcltupd_sdl=casesdlofPCLT_SDL_->sdlPCLT_SDL_ToTemplateLink_->sdl_->pcltRequiredSDLpcltupd_pclt=pclt{pcltRequiredSDL=upd_sdl}in(M.insertpclt_idupd_pcltprocessed_cat_accum,unprocessed_cat_map,err_msg_accum,upd_sdl)Nothing->casetakeFromMapref_pclt_idunprocessed_cat_mapof(Justunprocessed_refed_pclt,rest_unprocesseds)->let(processed_cat_accum2,unprocessed_cat_map2,err_msg_accum2,sdl)=determinePCLT_SDL(ref_pclt_id,unprocessed_refed_pclt)(processed_cat_accum,rest_unprocesseds,err_msg_accum,pclt_id:useds_buf)upd_sdl=casesdlofPCLT_SDL_->sdlPCLT_SDL_ToTemplateLink_->sdl_->pcltRequiredSDLpcltupd_pclt=pclt{pcltRequiredSDL=upd_sdl}in(M.insertpclt_idupd_pcltprocessed_cat_accum2,unprocessed_cat_map2,err_msg_accum2,upd_sdl)(Nothing,_)->(M.insertpclt_idpcltprocessed_cat_accum,unprocessed_cat_map,err_msg_accum++[err23pclt_idref_pclt_id],pcltRequiredSDLpclt)_->(M.insertpclt_idpcltprocessed_cat_accum,unprocessed_cat_map,err_msg_accum,pcltRequiredSDLpclt)------------------------------------------------------normalizeReferentialSDLs_metaCycle::(PCLT_CatalogMap,PCLT_CatalogMap,[DRL_NormalizationError])->(PCLT_CatalogMap,PCLT_CatalogMap,[DRL_NormalizationError])normalizeReferentialSDLs_metaCyclei@(processeds,unprocesseds,errs_accum)=caseM.nullunprocessedsofTrue->iFalse->let((pclt_id,pclt),rest_unprocesseds)=M.deleteFindMinunprocesseds(processeds2,unprocesseds2,errs_accum2,_)=determinePCLT_SDL(pclt_id,pclt)(processeds,rest_unprocesseds,errs_accum,[])innormalizeReferentialSDLs_metaCycle(processeds2,unprocesseds2,errs_accum2)------------------------------------------------------(results,_,result_errs_list)=normalizeReferentialSDLs_metaCycle(pclt_catalog_map,M.empty,[])in(results,result_errs_list)-------------------------------------------------------------------------- | Error type for 'adhoc_str2ldt'.dataAHSTR2LngTpl_Error=ParseFailure_AHS2PE[PCLT_ParserLowLevelFailure]|RequiredCompositeIsMissing_AHS2PERequiredCompositeIsMissing_PCLTEderiving(Show,Typeable)-- | Make a 'Text.PCLT.Template.LocalizedTemplate'-- out of a single 'ByteString'.adhoc_str2ldt::(Lazy.ByteString,LanguageName)->PCLT_Catalog->EitherAHSTR2LngTpl_ErrorLocalizedTemplateadhoc_str2ldt(str,lng)catalog=letcfg=pcltcInnerConfigcatalog(err_list,mb_pre_ldt)=doTheParsecfgstr-- ( [PCLT_ParserLowLevelFailure], Maybe ( LngTpl_AbstractedString, [PCLT_ID] ))_allow_untmpl_msgs=pcsAllowUntemplatedMessagescfgerr1subcomp_id=RequiredCompositeIsMissing_AHS2PE$RequiredCompositeIsMissing_PCLTEsubcomp_idincasemb_pre_ldtofNothing->Left$ParseFailure_AHS2PEerr_listJust(marked_str,composites_keys_list)->leterr_or_subcomposites_map=foldr(\subc_iderr_or_pclt_accum->caseerr_or_pclt_accumofLeft_->err_or_pclt_accumRightpclt_accum->caseM.lookupsubc_id(pcltcCatalogMapcatalog)ofNothing->case_allow_untmpl_msgsofTrue->err_or_pclt_accumFalse->Left$err1subc_idJustpclt->Right$M.insertsubc_idpcltpclt_accum)(RightM.empty)composites_keys_listincaseerr_or_subcomposites_mapofLefterr_msg->Lefterr_msgRightsub_lat_map->RightLocalizedTemplate{ldtAbstractedString=marked_str,ldtSubcompositesMap=sub_lat_map}-------------------------------------------------------------------------- | Make a 'Text.PCLT.Template.LocalizableTemplate'-- out of a single 'ByteString'.str2pclt::(PCLT_ID,PCLT_AllocatedShowDetalizationLevel)->(LanguageName,Lazy.ByteString)->PCLT_Catalog->Either(ErrorWithPCSCatalogReadPCSCatalogError)LocalizableTemplatestr2pclt(tpl_id,req_sdl)(lng,str)catalog=leterr_or_ldt=adhoc_str2ldt(str,lng)catalogincaseerr_or_ldtofRightldt->RightLocalizableTemplate{pcltLocalizationsMap=M.singletonlngldt,pcltRequiredSDL=req_sdl}Lefterr->Left$ErrorWithPCSCatalog(pcltcCatalogIDcatalog)$caseerrofParseFailure_AHS2PEll_errs_list->caselng==catDfltLngcatalogofTrue->ParseFailedForDefaultLng_RPCSCEtpl_idFalsell_errs_listFalse->ParseFailedForNondefaultLng_RPCSCEtpl_idFalselngll_errs_listRequiredCompositeIsMissing_AHS2PEred_id->RequiredCompositeIsMissing_RPCSCE$RequiredByRequirerCompositeIsMissing_PCLTEtpl_idred_id-- | Make a 'Text.PCLT.Template.LocalizableTemplate' out of list-- of 'ByteString's.str_list2pclt::(PCLT_ID,PCLT_AllocatedShowDetalizationLevel)->MapLanguageNameLazy.ByteString->PCLT_Catalog->(LocalizableTemplate,[ErrorWithPCSCatalogReadPCSCatalogError])str_list2pclt(tpl_id,req_sdl)str_mapcatalog=letso=catStrictOrientcatalogdflt_lng=catDfltLngcatalog(mb_err_or_pclt_w_dfltlng,nodfltlng_str_list)=let(mb_dfltlng_str,left_)=takeFromMapdflt_lngstr_mapin(mb_dfltlng_str>>=\str->return$str2pclt(tpl_id,req_sdl)(dflt_lng,str)catalog,left_)(errs_list1,pclt1,mb_dflt_ldt)=casemb_err_or_pclt_w_dfltlngofNothing->([],LocalizableTemplate{pcltLocalizationsMap=M.empty,pcltRequiredSDL=req_sdl},Nothing)Just(Lefterr)->([err],LocalizableTemplate{pcltLocalizationsMap=M.empty,pcltRequiredSDL=req_sdl},Nothing)Just(Rightpclt)->letdflt_ldt=pcltLocalizationsMappclt!dflt_lng-- compareStrictOrientationOnDefaultin([],pclt,Justdflt_ldt)dflt_persists=isJustmb_dflt_ldtinfoldr(\(lng,str)(pclt_accum,errs_accum)->leterr_or_pclt2=str2pclt(tpl_id,req_sdl)(lng,str)catalogincaseerr_or_pclt2ofLeftarpcsce->(pclt_accum,arpcsce:errs_accum)Rightpclt2->letgood_outcome=(pclt_accum{pcltLocalizationsMap=M.union(pcltLocalizationsMappclt_accum)(pcltLocalizationsMappclt2)},errs_accum)incasedflt_persistsofFalse->good_outcomeTrue->letcur_ldt=pcltLocalizationsMappclt2!lngdflt_ldt=fromJustmb_dflt_ldtincasecompareStrictOrientationOnDefaulttpl_idsocur_ldtdflt_ldtofTrue->good_outcomeFalse->leterr=ErrorWithPCSCatalog(pcltcCatalogIDcatalog)(DefaultLngTplComponentsParamsSetsDiffersFromOnesOfNondefault_RPCSCE$DefaultLngTplComponentsParamsSetsDiffersFromOnesOfNondefault_PCLTEtpl_idlng)in(pclt_accum,err:errs_accum))(pclt1,errs_list1)(M.toListnodfltlng_str_list)