summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevor Elliott <trevor@galois.com>2013-09-08 18:25:48 -0700
committerTrevor Elliott <trevor@galois.com>2013-09-08 18:25:48 -0700
commit4174458178cf484b15874ac8656e41fe35be46f3 (patch)
treecc737628b0ebc89210d3476ab47ca9ccae568f9d
parent13d4096e0668e9f80a8601122affc64f8be295de (diff)
downloadhaskell-data-kind-syntax.tar.gz
Add IfacePromotionInfodata-kind-syntax
* Remove the orphan instance for PromotionInfo from types/TyCon.lhs
-rw-r--r--compiler/iface/IfaceSyn.lhs29
-rw-r--r--compiler/iface/MkIface.lhs9
-rw-r--r--compiler/iface/TcIface.lhs9
3 files changed, 33 insertions, 14 deletions
diff --git a/compiler/iface/IfaceSyn.lhs b/compiler/iface/IfaceSyn.lhs
index ca772ac963..5fd3e020b9 100644
--- a/compiler/iface/IfaceSyn.lhs
+++ b/compiler/iface/IfaceSyn.lhs
@@ -23,6 +23,7 @@ module IfaceSyn (
IfaceInfoItem(..), IfaceRule(..), IfaceAnnotation(..), IfaceAnnTarget,
IfaceClsInst(..), IfaceFamInst(..), IfaceTickish(..),
IfaceBang(..), IfaceAxBranch(..),
+ IfacePromotionInfo(..),
-- Misc
ifaceDeclImplicitBndrs, visibleIfConDecls,
@@ -37,7 +38,6 @@ module IfaceSyn (
#include "HsVersions.h"
-import TyCon( PromotionInfo(..) )
import IfaceType
import PprCore() -- Printing DFunArgs
import Demand
@@ -91,7 +91,7 @@ data IfaceDecl
ifCtxt :: IfaceContext, -- The "stupid theta"
ifCons :: IfaceConDecls, -- Includes new/data/data family info
ifRec :: RecFlag, -- Recursive or not?
- ifPromotable :: PromotionInfo (),-- Promotable to kind level?
+ ifPromotable :: IfacePromotionInfo,-- Promotable to kind level?
ifGadtSyntax :: Bool, -- True <=> declared using
-- GADT syntax
ifAxiom :: Maybe IfExtName -- The axiom, for a newtype,
@@ -242,17 +242,22 @@ instance Binary IfaceDecl where
return (IfaceDataKind occ a2 a3 a4)
_ -> error ("Binary.get(TyClDecl): Unknown tag " ++ show h)
-instance Binary (PromotionInfo ()) where
+data IfacePromotionInfo
+ = IfaceNeverPromote
+ | IfaceNotPromotable
+ | IfacePromotable
+
+instance Binary IfacePromotionInfo where
put_ bh p = case p of
- NeverPromote -> putByte bh 0x0
- NotPromotable -> putByte bh 0x1
- Promotable () -> putByte bh 0x2
+ IfaceNeverPromote -> putByte bh 0x0
+ IfaceNotPromotable -> putByte bh 0x1
+ IfacePromotable -> putByte bh 0x2
get bh = do
tag <- getByte bh
case tag of
- 0x0 -> return NeverPromote
- 0x1 -> return NotPromotable
- 0x2 -> return (Promotable ())
+ 0x0 -> return IfaceNeverPromote
+ 0x1 -> return IfaceNotPromotable
+ 0x2 -> return IfacePromotable
_ -> error ("Binary.get(Promotable ()): Unknown tag " ++ show tag)
data IfaceSynTyConRhs
@@ -1105,9 +1110,9 @@ pprIfaceDecl (IfaceData {ifName = tycon, ifCType = cType,
, pprAxiom mbAxiom])
where
pp_prom = case is_prom of
- NeverPromote -> ptext (sLit "Never promotable")
- NotPromotable -> ptext (sLit "Not promotable")
- Promotable () -> ptext (sLit "Promotable")
+ IfaceNeverPromote -> ptext (sLit "Never promotable")
+ IfaceNotPromotable -> ptext (sLit "Not promotable")
+ IfacePromotable -> ptext (sLit "Promotable")
pp_nd = case condecls of
IfAbstractTyCon dis -> ptext (sLit "abstract") <> parens (ppr dis)
diff --git a/compiler/iface/MkIface.lhs b/compiler/iface/MkIface.lhs
index 3fff2b81c7..ed96a533fb 100644
--- a/compiler/iface/MkIface.lhs
+++ b/compiler/iface/MkIface.lhs
@@ -1514,7 +1514,8 @@ tyConToIfaceDecl env tycon
ifCons = ifaceConDecls (algTyConRhs tycon),
ifRec = boolToRecFlag (isRecursiveTyCon tycon),
ifGadtSyntax = isGadtSyntaxTyCon tycon,
- ifPromotable = fmap (\_ -> ()) (promotableTyConInfo tycon),
+ ifPromotable = toIfacePromotionInfo
+ $ fmap (\_ -> ()) (promotableTyConInfo tycon),
ifAxiom = fmap coAxiomName (tyConFamilyCoercion_maybe tycon) }
| isForeignTyCon tycon
@@ -1571,6 +1572,12 @@ tyConToIfaceDecl env tycon
where
(args,_) = splitFunTys (tyConKind ty_con)
+toIfacePromotionInfo :: PromotionInfo () -> IfacePromotionInfo
+toIfacePromotionInfo pi = case pi of
+ NeverPromote -> IfaceNeverPromote
+ NotPromotable -> IfaceNotPromotable
+ Promotable () -> IfacePromotable
+
toIfaceBang :: TidyEnv -> HsBang -> IfaceBang
toIfaceBang _ HsNoBang = IfNoBang
toIfaceBang _ (HsUnpack Nothing) = IfUnpack
diff --git a/compiler/iface/TcIface.lhs b/compiler/iface/TcIface.lhs
index 2d18a74d1b..6c37654a51 100644
--- a/compiler/iface/TcIface.lhs
+++ b/compiler/iface/TcIface.lhs
@@ -473,10 +473,17 @@ tc_iface_decl parent _ (IfaceData {ifName = occ_name,
; parent' <- tc_parent tyvars mb_axiom_name
; cons <- tcIfaceDataCons tc_name tycon tyvars rdr_cons
; return (buildAlgTyCon tc_name tyvars roles cType stupid_theta
- cons is_rec is_prom gadt_syn parent') }
+ cons is_rec is_prom' gadt_syn parent') }
; traceIf (text "tcIfaceDecl4" <+> ppr tycon)
; return (ATyCon tycon) }
where
+
+ is_prom' :: PromotionInfo ()
+ is_prom' = case is_prom of
+ IfaceNeverPromote -> NeverPromote
+ IfaceNotPromotable -> NotPromotable
+ IfacePromotable -> Promotable ()
+
tc_parent :: [TyVar] -> Maybe Name -> IfL TyConParent
tc_parent _ Nothing = return parent
tc_parent tyvars (Just ax_name)