diff options
author | Manuel M T Chakravarty <chak@cse.unsw.edu.au> | 2006-09-15 21:19:18 +0000 |
---|---|---|
committer | Manuel M T Chakravarty <chak@cse.unsw.edu.au> | 2006-09-15 21:19:18 +0000 |
commit | 108361d05dfb0aa37871c2c6a4ddec45a1b68010 (patch) | |
tree | ca1c75cf9364d9a75929fbc4c74860015b33337b /compiler/hsSyn/HsBinds.lhs | |
parent | bd865113a1446bb18fb32b546b8776b846a23116 (diff) | |
download | haskell-108361d05dfb0aa37871c2c6a4ddec45a1b68010.tar.gz |
Massive patch for the first months work adding System FC to GHC #14
Fri Aug 4 15:59:09 EDT 2006 Manuel M T Chakravarty <chak@cse.unsw.edu.au>
* Massive patch for the first months work adding System FC to GHC #14
Broken up massive patch -=chak
Original log message:
This is (sadly) all done in one patch to avoid Darcs bugs.
It's not complete work... more FC stuff to come. A compiler
using just this patch will fail dismally.
Diffstat (limited to 'compiler/hsSyn/HsBinds.lhs')
-rw-r--r-- | compiler/hsSyn/HsBinds.lhs | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/compiler/hsSyn/HsBinds.lhs b/compiler/hsSyn/HsBinds.lhs index 31c1cae459..940b6d3e24 100644 --- a/compiler/hsSyn/HsBinds.lhs +++ b/compiler/hsSyn/HsBinds.lhs @@ -16,7 +16,9 @@ import {-# SOURCE #-} HsExpr ( HsExpr, pprExpr, LHsExpr, import {-# SOURCE #-} HsPat ( LPat ) import HsTypes ( LHsType, PostTcType ) -import Type ( Type ) +import PprCore ( {- instances -} ) +import Coercion ( Coercion ) +import Type ( Type, pprParendType ) import Name ( Name ) import NameSet ( NameSet, elemNameSet ) import BasicTypes ( IPName, RecFlag(..), InlineSpec(..), Fixity ) @@ -296,20 +298,43 @@ instance (OutputableBndr id) => Outputable (IPBind id) where %************************************************************************ \begin{code} --- A Coercion is an expression with a hole in it +-- A ExprCoFn is an expression with a hole in it -- We need coercions to have concrete form so that we can zonk them data ExprCoFn = CoHole -- The identity coercion - | CoCompose ExprCoFn ExprCoFn - | CoApps ExprCoFn [Id] -- Non-empty list - | CoTyApps ExprCoFn [Type] -- in all of these - | CoLams [Id] ExprCoFn -- so that the identity coercion - | CoTyLams [TyVar] ExprCoFn -- is just Hole - | CoLet (LHsBinds Id) ExprCoFn -- Would be nicer to be core bindings + + | CoCompose ExprCoFn ExprCoFn -- (\a1..an. []) `CoCompose` (\x1..xn. []) + -- = (\a1..an \x1..xn. []) + + | ExprCoFn Coercion -- A cast: [] `cast` co + -- Guaranteedn not the identity coercion + + -- Non-empty list in all of these, so that the identity coercion + -- is always exactly CoHole, not, say, (CoTyLams []) + | CoApps [Var] -- [] x1 .. xn; the xi are dicts or coercions + | CoTyApps [Type] -- [] t1 .. tn + | CoLams [Id] -- \x1..xn. []; the xi are dicts or coercions + | CoTyLams [TyVar] -- \a1..an. [] + | CoLet (LHsBinds Id) -- Would be nicer to be core bindings + +instance Outputable ExprCoFn where + ppr CoHole = ptext SLIT("<>") + ppr (ExprCoFn co) = ppr co + ppr (CoApps ids) = ppr CoHole <+> interppSP ids + ppr (CoTyApps tys) = ppr CoHole <+> hsep (map pprParendType tys) + ppr (CoTyLams tvs) = sep [ptext SLIT("/\\") <> hsep (map (pprBndr LambdaBind) tvs), + ptext SLIT("->") <+> ppr CoHole] + ppr (CoLams ids) = sep [ptext SLIT("\\") <> hsep (map (pprBndr LambdaBind) ids), + ptext SLIT("->") <+> ppr CoHole] + ppr (CoLet binds) = sep [ptext SLIT("let") <+> braces (ppr binds), + ppr CoHole] + ppr (CoCompose co1 co2) = sep [ppr co1, ptext SLIT("<.>"), ppr co2] (<.>) :: ExprCoFn -> ExprCoFn -> ExprCoFn -(<.>) = CoCompose +CoHole <.> c = c +c <.> CoHole = c +c1 <.> c2 = c1 `CoCompose` c2 idCoercion :: ExprCoFn idCoercion = CoHole |