-- Check that the stupid theta is empty for a GADT-style declaration
; checkTc (null stupid_theta || h98_syntax) (badStupidTheta tc_name)
+ -- Check that a newtype has exactly one constructor
+ -- Do this before checking for empty data decls, so that
+ -- we don't suggest -XEmptyDataDecls for newtypes
+ ; checkTc (new_or_data == DataType || isSingleton cons)
+ (newtypeConError tc_name (length cons))
+
-- Check that there's at least one condecl,
-- or else we're reading an hs-boot file, or -XEmptyDataDecls
; checkTc (not (null cons) || empty_data_decls || is_boot)
(emptyConDeclsErr tc_name)
- -- Check that a newtype has exactly one constructor
- ; checkTc (new_or_data == DataType || isSingleton cons)
- (newtypeConError tc_name (length cons))
-
; tycon <- fixM (\ tycon -> do
{ data_cons <- mapM (addLocM (tcConDecl unbox_strict ex_ok tycon final_tvs))
cons
tycon_name = tyConName (classTyCon clas)
tc_isrec = calc_isrec tycon_name
in
- buildClass class_name tvs' ctxt' fds' ats'
+ buildClass False {- Must include unfoldings for selectors -}
+ class_name tvs' ctxt' fds' ats'
sig_stuff tc_isrec)
; return (AClass clas : ats')
-- NB: Order is important due to the call to `mkGlobalThings' when