Commit 8c2fd740 authored by batterseapower's avatar batterseapower
Browse files

Rename maybeTyConSingleCon to tyConSingleDataCon_maybe

parent 51d54e10
......@@ -710,7 +710,7 @@ To-do
* Bogus report of overlapped pattern for
f (R {field = [c]}) = 1
f (R {}) = 2
This shows up for TyCon.maybeTyConSingleCon
This shows up for TyCon.tyConSingleDataCon_maybe
* > module Main( main ) where
......
......@@ -380,6 +380,6 @@ showTypeCategory ty
else if isPrimTyCon tycon {- array, we hope -} then 'A' -- Bogus
else if isEnumerationTyCon tycon then 'E'
else if isTupleTyCon tycon then 'T'
else if isJust (maybeTyConSingleCon tycon) then 'S'
else if isJust (tyConSingleDataCon_maybe tycon) then 'S'
else if utc == listTyConKey then 'L'
else 'M' -- oh, well...
......@@ -386,7 +386,7 @@ ppr_termM1 NewtypeWrap{} = panic "ppr_termM1 - NewtypeWrap"
pprNewtypeWrap y p NewtypeWrap{ty=ty, wrapped_term=t}
| Just (tc,_) <- splitNewTyConApp_maybe ty
, ASSERT(isNewTyCon tc) True
, Just new_dc <- maybeTyConSingleCon tc = do
, Just new_dc <- tyConSingleDataCon_maybe tc = do
real_term <- y max_prec t
return$ cparen (p >= app_prec) (ppr new_dc <+> real_term)
pprNewtypeWrap _ _ _ = panic "pprNewtypeWrap"
......@@ -682,7 +682,7 @@ cvObtainTerm hsc_env bound force mb_ty hval = runTR hsc_env $ do
| Just (tc, args) <- splitNewTyConApp_maybe ty
, isNewTyCon tc
, wrapped_type <- newTyConInstRhs tc args
, Just dc <- maybeTyConSingleCon tc
, Just dc <- tyConSingleDataCon_maybe tc
, t' <- expandNewtypes t{ ty = wrapped_type
, subTerms = map expandNewtypes tt }
= NewtypeWrap ty (Right dc) t'
......
......@@ -156,7 +156,7 @@ gen_Eq_binds loc tycon
no_nullary_cons = null nullary_cons
rest | no_nullary_cons
= case maybeTyConSingleCon tycon of
= case tyConSingleDataCon_maybe tycon of
Just _ -> []
Nothing -> -- if cons don't match, then False
[([nlWildPat, nlWildPat], false_Expr)]
......@@ -680,7 +680,7 @@ gen_Ix_binds loc tycon
= listToBag [single_con_range, single_con_index, single_con_inRange]
data_con
= case maybeTyConSingleCon tycon of -- just checking...
= case tyConSingleDataCon_maybe tycon of -- just checking...
Nothing -> panic "get_Ix_binds"
Just dc | any isUnLiftedType (dataConOrigArgTys dc)
-> pprPanic "Can't derive Ix for a single-constructor type with primitive argument types:" (ppr tycon)
......
......@@ -61,7 +61,7 @@ module TyCon(
synTyConDefn, synTyConRhs, synTyConType, synTyConResKind,
tyConExtName, -- External name for foreign types
maybeTyConSingleCon,
tyConSingleDataCon_maybe,
-- Generics
tyConHasGenerics
......@@ -932,14 +932,14 @@ synTyConResKind tycon = pprPanic "synTyConResKind" (ppr tycon)
\end{code}
\begin{code}
maybeTyConSingleCon :: TyCon -> Maybe DataCon
maybeTyConSingleCon (AlgTyCon {algTcRhs = DataTyCon {data_cons = [c] }}) = Just c
maybeTyConSingleCon (AlgTyCon {algTcRhs = NewTyCon { data_con = c }}) = Just c
maybeTyConSingleCon (AlgTyCon {}) = Nothing
maybeTyConSingleCon (TupleTyCon {dataCon = con}) = Just con
maybeTyConSingleCon (PrimTyCon {}) = Nothing
maybeTyConSingleCon (FunTyCon {}) = Nothing -- case at funty
maybeTyConSingleCon tc = pprPanic "maybeTyConSingleCon: unexpected tycon " $ ppr tc
tyConSingleDataCon_maybe :: TyCon -> Maybe DataCon
tyConSingleDataCon_maybe (AlgTyCon {algTcRhs = DataTyCon {data_cons = [c] }}) = Just c
tyConSingleDataCon_maybe (AlgTyCon {algTcRhs = NewTyCon { data_con = c }}) = Just c
tyConSingleDataCon_maybe (AlgTyCon {}) = Nothing
tyConSingleDataCon_maybe (TupleTyCon {dataCon = con}) = Just con
tyConSingleDataCon_maybe (PrimTyCon {}) = Nothing
tyConSingleDataCon_maybe (FunTyCon {}) = Nothing -- case at funty
tyConSingleDataCon_maybe tc = pprPanic "tyConSingleDataCon_maybe: unexpected tycon " $ ppr tc
\end{code}
\begin{code}
......
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