Make records with less fields still abstract (#397)

This commit is contained in:
Neil Mitchell 2019-04-11 16:53:47 +01:00 committed by GitHub
parent 14fdafede8
commit a55c9cf7e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -105,7 +105,7 @@ instanceTemplate abstract selector record field = ClsInstD noE $ ClsInstDecl noE
onDecl :: LHsDecl GhcPs -> [LHsDecl GhcPs]
onDecl o@(L _ (GHC.TyClD _ x)) = o :
[ noL $ InstD noE $ instanceTemplate (length fields >= 3 && length ctors == 1) field (unLoc record) typ
[ noL $ InstD noE $ instanceTemplate (length ctors == 1) field (unLoc record) typ
| let fields = nubOrdOn (\(_,_,x,_) -> GHC.occNameFS $ GHC.rdrNameOcc $ unLoc $ rdrNameFieldOcc x) $ getFields x
, (record, _, field, typ) <- fields]
where ctors = dd_cons $ tcdDataDefn x