Commit 9cb289ab authored by Ryan Scott's avatar Ryan Scott
Browse files

Remove hack put in place for #12512

Summary:
Previously, I added an ad hoc check for unboxed tuples and
sums in standalone-derived instances to fix #12512, under the
pretense that polymorphism over `UnboxedTupleRep` and
`UnboxedSumRep` was a lie. But that is no longer the case, and so
this ad hoc check can be removed entirely. Less code, and easier to
understand.

Test Plan: make test TEST=T12512

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

Differential Revision: https://phabricator.haskell.org/D4271
parent 9caf40e9
...@@ -638,12 +638,6 @@ deriveStandalone (L loc (DerivDecl deriv_ty deriv_strat' overlap_mode)) ...@@ -638,12 +638,6 @@ deriveStandalone (L loc (DerivDecl deriv_ty deriv_strat' overlap_mode))
-> do warnUselessTypeable -> do warnUselessTypeable
return Nothing return Nothing
| isUnboxedTupleTyCon tc
-> bale_out $ unboxedTyConErr "tuple"
| isUnboxedSumTyCon tc
-> bale_out $ unboxedTyConErr "sum"
| isAlgTyCon tc || isDataFamilyTyCon tc -- All other classes | isAlgTyCon tc || isDataFamilyTyCon tc -- All other classes
-> do { spec <- mkEqnHelp (fmap unLoc overlap_mode) -> do { spec <- mkEqnHelp (fmap unLoc overlap_mode)
tvs cls cls_tys tc tc_args tvs cls cls_tys tc tc_args
...@@ -973,7 +967,7 @@ mkEqnHelp overlap_mode tvs cls cls_tys tycon tc_args mtheta deriv_strat ...@@ -973,7 +967,7 @@ mkEqnHelp overlap_mode tvs cls cls_tys tycon tc_args mtheta deriv_strat
, denv_mtheta = mtheta , denv_mtheta = mtheta
, denv_strat = deriv_strat } , denv_strat = deriv_strat }
; flip runReaderT deriv_env $ ; flip runReaderT deriv_env $
if isDataTyCon rep_tc then mkDataTypeEqn else mkNewTypeEqn } if isNewTyCon rep_tc then mkNewTypeEqn else mkDataTypeEqn }
where where
bale_out msg = failWithTc (derivingThingErr False cls cls_tys bale_out msg = failWithTc (derivingThingErr False cls cls_tys
(mkTyConApp tycon tc_args) deriv_strat msg) (mkTyConApp tycon tc_args) deriv_strat msg)
...@@ -1932,7 +1926,3 @@ derivingHiddenErr tc ...@@ -1932,7 +1926,3 @@ derivingHiddenErr tc
standaloneCtxt :: LHsSigType GhcRn -> SDoc standaloneCtxt :: LHsSigType GhcRn -> SDoc
standaloneCtxt ty = hang (text "In the stand-alone deriving instance for") standaloneCtxt ty = hang (text "In the stand-alone deriving instance for")
2 (quotes (ppr ty)) 2 (quotes (ppr ty))
unboxedTyConErr :: String -> MsgDoc
unboxedTyConErr thing =
text "The last argument of the instance cannot be an unboxed" <+> text thing
T12512.hs:10:1: error: T12512.hs:10:1: error:
• Can't make a derived instance of ‘Wat1 (# a, b #)’: • Can't make a derived instance of ‘Wat1 (# a, b #)’:
The last argument of the instance cannot be an unboxed tuple ‘Wat1’ is not a stock derivable class (Eq, Show, etc.)
Try enabling DeriveAnyClass
• In the stand-alone deriving instance for ‘Wat1 (# a, b #)’ • In the stand-alone deriving instance for ‘Wat1 (# a, b #)’
T12512.hs:13:1: error: T12512.hs:13:1: error:
• Can't make a derived instance of ‘Wat2 (# a | b #)’: • Can't make a derived instance of ‘Wat2 (# a | b #)’:
The last argument of the instance cannot be an unboxed sum ‘Wat2’ is not a stock derivable class (Eq, Show, etc.)
Try enabling DeriveAnyClass
• In the stand-alone deriving instance for ‘Wat2 (# a | b #)’ • In the stand-alone deriving instance for ‘Wat2 (# a | b #)’
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment