summaryrefslogtreecommitdiff
path: root/compiler/iface/MkIface.lhs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2012-12-23 15:38:48 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2012-12-23 15:38:48 +0000
commit1ee1cd4194555e498d05bfc391b7b0e635d11e29 (patch)
tree96db09d1078848cd4a9ef66972fb3d5310512b03 /compiler/iface/MkIface.lhs
parentd3e2912ac2048346828539e0dfef6c0cefef0d38 (diff)
downloadhaskell-1ee1cd4194555e498d05bfc391b7b0e635d11e29.tar.gz
Make {-# UNPACK #-} work for type/data family invocations
This fixes most of Trac #3990. Consider data family D a data instance D Double = CD Int Int data T = T {-# UNPACK #-} !(D Double) Then we want the (D Double unpacked). To do this we need to construct a suitable coercion, and it's much safer to record that coercion in the interface file, lest the in-scope instances differ somehow. That in turn means elaborating the HsBang type to include a coercion. To do that I moved HsBang from BasicTypes to DataCon, which caused quite a few minor knock-on changes. Interface-file format has changed! Still to do: need to do knot-tying to allow instances to take effect within the same module.
Diffstat (limited to 'compiler/iface/MkIface.lhs')
-rw-r--r--compiler/iface/MkIface.lhs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/iface/MkIface.lhs b/compiler/iface/MkIface.lhs
index 217dad305a..50c775fc7f 100644
--- a/compiler/iface/MkIface.lhs
+++ b/compiler/iface/MkIface.lhs
@@ -1505,7 +1505,7 @@ tyConToIfaceDecl env tycon
ifConArgTys = map (tidyToIfaceType env2) arg_tys,
ifConFields = map getOccName
(dataConFieldLabels data_con),
- ifConStricts = dataConRepBangs data_con }
+ ifConStricts = map (toIfaceBang env2) (dataConRepBangs data_con) }
where
(univ_tvs, ex_tvs, eq_spec, theta, arg_tys, _) = dataConFullSig data_con
@@ -1516,6 +1516,12 @@ tyConToIfaceDecl env tycon
to_eq_spec spec = [ (getOccName (tidyTyVar env2 tv), tidyToIfaceType env2 ty)
| (tv,ty) <- spec]
+toIfaceBang :: TidyEnv -> HsBang -> IfaceBang
+toIfaceBang _ HsNoBang = IfNoBang
+toIfaceBang _ (HsUnpack Nothing) = IfUnpack
+toIfaceBang env (HsUnpack (Just co)) = IfUnpackCo (coToIfaceType (tidyCo env co))
+toIfaceBang _ HsStrict = IfStrict
+toIfaceBang _ (HsBang {}) = panic "toIfaceBang"
classToIfaceDecl :: TidyEnv -> Class -> IfaceDecl
classToIfaceDecl env clas