{- |
Support for creating Show instances using the accessors.
-}moduleData.Accessor.Show(field,showsPrec)whereimportqualifiedData.Accessor.BasicasAccessorimportData.Maybe(catMaybes)importqualifiedText.ShowasShowimportPreludehiding(showsPrec)toMaybe::Bool->a->MaybeatoMaybeFalse_=NothingtoMaybeTruex=Justxfield::(Showa,Eqa)=>String->Accessor.Tra->r->r->MaybeShowSfieldnameaccdefltrecord=letx=Accessor.getaccrecordintoMaybe(x/=Accessor.getaccdeflt)(showStringname.showString" ^= ".Show.showsPrec5x)showsPrec::[r->r->MaybeShowS]->String->r->Int->r->ShowSshowsPrecfieldsdefltNamedefltprecord=letcalls=catMaybes$map(\f->fdefltrecord)$fieldsinifnullcallsthenshowStringdefltNameelseshowParen(p>0)(foldr(\accs->acc.showString" $ ".s)(showStringdefltName)calls)