Skip to content

Commit

Permalink
Typechecker: refactoring only
Browse files Browse the repository at this point in the history
* don't call `nlHsPar`, as `genOpApp` already does so.
* don't reimplement `isUnboxedTupleTyCon` and `isBoxedTupleTyCon`.

Reviewed By: austin

Differential Revision: https://phabricator.haskell.org/D798
  • Loading branch information
thomie committed Apr 7, 2015
1 parent 93f3a64 commit f745b6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions compiler/typecheck/TcGenDeriv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,8 @@ gen_Show_binds get_fixity loc tycon
([a_Pat, con_pat], nlHsPar (nested_compose_Expr show_thingies))
| otherwise =
([a_Pat, con_pat],
showParen_Expr (nlHsPar (genOpApp a_Expr ge_RDR
(nlHsLit (HsInt "" con_prec_plus_one))))
showParen_Expr (genOpApp a_Expr ge_RDR
(nlHsLit (HsInt "" con_prec_plus_one)))
(nlHsPar (nested_compose_Expr show_thingies)))
where
data_con_RDR = getRdrName data_con
Expand Down
7 changes: 2 additions & 5 deletions compiler/types/TyCon.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1189,9 +1189,7 @@ isPrimTyCon _ = False
-- only be true for primitive and unboxed-tuple 'TyCon's
isUnLiftedTyCon :: TyCon -> Bool
isUnLiftedTyCon (PrimTyCon {isUnLifted = is_unlifted}) = is_unlifted
isUnLiftedTyCon (TupleTyCon {tyConTupleSort = sort})
= not (isBoxed (tupleSortBoxity sort))
isUnLiftedTyCon _ = False
isUnLiftedTyCon tc = isUnboxedTupleTyCon tc

-- | Returns @True@ if the supplied 'TyCon' resulted from either a
-- @data@ or @newtype@ declaration
Expand All @@ -1217,8 +1215,7 @@ isDataTyCon (AlgTyCon {algTcRhs = rhs})
NewTyCon {} -> False
DataFamilyTyCon {} -> False
AbstractTyCon {} -> False -- We don't know, so return False
isDataTyCon (TupleTyCon {tyConTupleSort = sort}) = isBoxed (tupleSortBoxity sort)
isDataTyCon _ = False
isDataTyCon tc = isBoxedTupleTyCon tc

-- | 'isDistinctTyCon' is true of 'TyCon's that are equal only to
-- themselves, even via coercions (except for unsafeCoerce).
Expand Down
2 changes: 1 addition & 1 deletion testsuite/tests/deriving/should_run/T9576.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ T9576: T9576.hs:6:31:
In the second argument of ‘showParen’, namely
‘((.) (showString "MkBar ") (showsPrec 11 b1))’
In the expression:
showParen ((a >= 11)) ((.) (showString "MkBar ") (showsPrec 11 b1))
showParen (a >= 11) ((.) (showString "MkBar ") (showsPrec 11 b1))
When typechecking the code for ‘showsPrec’
in a derived instance for ‘Show Bar’:
To see the code I am typechecking, use -ddump-deriv
Expand Down

0 comments on commit f745b6e

Please sign in to comment.