{-# LANGUAGE CPP #-}moduleAgda.Utils.MapwhereimportPreludehiding(map,lookup,mapM)importControl.ApplicativeimportData.MapimportData.TraversableimportAgda.Utils.Monad#include "../undefined.h"importAgda.Utils.ImpossibledataEitherOrBothab=La|Bab|Rb-- | Not very efficient (goes via a list), but it'll do.unionWithM::(Ordk,Functorm,Monadm)=>(a->a->ma)->Mapka->Mapka->m(Mapka)unionWithMfm1m2=fromList<$>mapMcombine(toListm)wherem=unionWithboth(mapLm1)(mapRm2)both(La)(Rb)=Babboth__=__IMPOSSIBLE__combine(k,Bab)=(,)k<$>fabcombine(k,La)=return(k,a)combine(k,Rb)=return(k,b)insertWithKeyM::(Ordk,Monadm)=>(k->a->a->ma)->k->a->Mapka->m(Mapka)insertWithKeyMclashkxm=caselookupkmofJusty->doz<-clashkxyreturn$insertkzmNothing->return$insertkxm-- | Filter a map based on the keys.filterKeys::Ordk=>(k->Bool)->Mapka->MapkafilterKeysp=filterWithKey(const.p)