synTyConDefn, synTyConRhs, synTyConType, synTyConResKind,
tyConExtName, -- External name for foreign types
- maybeTyConSingleCon,
+ tyConSingleDataCon_maybe,
-- Generics
tyConHasGenerics
tyConName :: Name,
tyConArity :: Arity,
coKindFun :: [Type] -> (Type,Type)
- } -- INVARAINT: coKindFun is always applied to exactly 'arity' args
+ } -- INVARIANT: coKindFun is always applied to exactly 'arity' args
-- E.g. for trans (c1 :: ta=tb) (c2 :: tb=tc), the coKindFun returns
-- the kind as a pair of types: (ta,tc)
w2 :: Foo T
w2 = MkFoo (\(MkT x) -> case w1 of MkFoo f -> f x)
-After desugaring, and discading the data constructors for the newtypes,
+After desugaring, and discarding the data constructors for the newtypes,
we get:
w2 :: Foo T
w2 = w1
\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}