diff options
Diffstat (limited to 'compiler/deSugar')
| -rw-r--r-- | compiler/deSugar/Check.lhs | 33 | ||||
| -rw-r--r-- | compiler/deSugar/Desugar.lhs | 57 | ||||
| -rw-r--r-- | compiler/deSugar/DsArrows.lhs | 53 | ||||
| -rw-r--r-- | compiler/deSugar/DsBinds.lhs | 42 | ||||
| -rw-r--r-- | compiler/deSugar/DsCCall.lhs | 65 | ||||
| -rw-r--r-- | compiler/deSugar/DsExpr.lhs | 77 | ||||
| -rw-r--r-- | compiler/deSugar/DsForeign.lhs | 65 | ||||
| -rw-r--r-- | compiler/deSugar/DsGRHSs.lhs | 25 | ||||
| -rw-r--r-- | compiler/deSugar/DsListComp.lhs | 36 | ||||
| -rw-r--r-- | compiler/deSugar/DsMeta.hs | 61 | ||||
| -rw-r--r-- | compiler/deSugar/DsMonad.lhs | 45 | ||||
| -rw-r--r-- | compiler/deSugar/DsUtils.lhs | 58 | ||||
| -rw-r--r-- | compiler/deSugar/Match.lhs | 48 | ||||
| -rw-r--r-- | compiler/deSugar/MatchCon.lhs | 22 | ||||
| -rw-r--r-- | compiler/deSugar/MatchLit.lhs | 35 | ||||
| -rw-r--r-- | compiler/deSugar/deSugar.tex | 23 |
16 files changed, 332 insertions, 413 deletions
diff --git a/compiler/deSugar/Check.lhs b/compiler/deSugar/Check.lhs index dbf2d72dc7..15fcf39405 100644 --- a/compiler/deSugar/Check.lhs +++ b/compiler/deSugar/Check.lhs @@ -1,36 +1,31 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1997-1998 % % Author: Juan J. Quintela <quintela@krilin.dc.fi.udc.es> -\section{Module @Check@ in @deSugar@} \begin{code} - - module Check ( check , ExhaustivePat ) where +#include "HsVersions.h" import HsSyn -import TcHsSyn ( hsLPatType, mkVanillaTuplePat ) -import TcType ( tcTyConAppTyCon ) -import DsUtils ( EquationInfo(..), MatchResult(..), - CanItFail(..), firstPat ) -import MatchLit ( tidyLitPat, tidyNPat ) -import Id ( Id, idType ) -import DataCon ( DataCon, dataConTyCon, dataConOrigArgTys, dataConFieldLabels ) -import Name ( Name, mkInternalName, getOccName, isDataSymOcc, - getName, mkVarOccFS ) +import TcHsSyn +import TcType +import DsUtils +import MatchLit +import Id +import DataCon +import Name import TysWiredIn -import PrelNames ( unboundKey ) -import TyCon ( tyConDataCons, tupleTyConBoxity, isTupleTyCon ) -import BasicTypes ( Boxity(..) ) -import SrcLoc ( noSrcLoc, Located(..), unLoc, noLoc ) +import PrelNames +import TyCon +import BasicTypes +import SrcLoc import UniqSet -import Util ( takeList, splitAtList, notNull ) +import Util import Outputable import FastString - -#include "HsVersions.h" \end{code} This module performs checks about if one list of equations are: diff --git a/compiler/deSugar/Desugar.lhs b/compiler/deSugar/Desugar.lhs index 29801f28cd..8fcaf9b93a 100644 --- a/compiler/deSugar/Desugar.lhs +++ b/compiler/deSugar/Desugar.lhs @@ -1,50 +1,49 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[Desugar]{@deSugar@: the main function} + +The Desugarer: turning HsSyn into Core. \begin{code} module Desugar ( deSugar, deSugarExpr ) where #include "HsVersions.h" -import DynFlags ( DynFlag(..), DynFlags(..), dopt, GhcMode(..) ) -import StaticFlags ( opt_SccProfilingOn, - opt_AutoSccsOnAllToplevs, - opt_AutoSccsOnExportedToplevs ) -import DriverPhases ( isHsBoot ) -import HscTypes ( ModGuts(..), HscEnv(..), availsToNameSet, - Dependencies(..), ForeignStubs(..), TypeEnv, IsBootInterface ) -import HsSyn ( RuleDecl(..), RuleBndr(..), LHsExpr, LRuleDecl ) -import TcRnTypes ( TcGblEnv(..), ImportAvails(..) ) -import MkIface ( mkUsageInfo ) -import Id ( Id, setIdExported, idName ) -import Name ( Name, isExternalName, nameIsLocalOrFrom, nameOccName ) +import DynFlags +import StaticFlags +import HscTypes +import HsSyn +import TcRnTypes +import MkIface +import Id +import Name import CoreSyn -import PprCore ( pprRules, pprCoreExpr ) +import PprCore import DsMonad -import DsExpr ( dsLExpr ) -import DsBinds ( dsTopLHsBinds, decomposeRuleLhs, AutoScc(..) ) -import DsForeign ( dsForeigns ) +import DsExpr +import DsBinds +import DsForeign import DsExpr () -- Forces DsExpr to be compiled; DsBinds only -- depends on DsExpr.hi-boot. import Module -import UniqFM ( eltsUFM, delFromUFM ) -import PackageConfig ( thPackageId ) -import RdrName ( GlobalRdrEnv ) +import UniqFM +import PackageConfig +import RdrName import NameSet import VarSet -import Rules ( roughTopNames ) -import CoreLint ( showPass, endPass ) -import CoreFVs ( ruleRhsFreeVars, exprsFreeNames ) -import ErrUtils ( doIfSet, dumpIfSet_dyn ) -import ListSetOps ( insertList ) +import Rules +import CoreLint +import CoreFVs +import ErrUtils +import ListSetOps import Outputable -import SrcLoc ( Located(..) ) -import DATA_IOREF ( readIORef ) -import Maybes ( catMaybes ) +import SrcLoc +import Maybes import FastString -import Util ( sortLe ) +import Util + +import Data.IORef \end{code} %************************************************************************ diff --git a/compiler/deSugar/DsArrows.lhs b/compiler/deSugar/DsArrows.lhs index 4251b2011c..4d9295d6ae 100644 --- a/compiler/deSugar/DsArrows.lhs +++ b/compiler/deSugar/DsArrows.lhs @@ -1,23 +1,21 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[DsArrows]{Desugaring arrow commands} + +Desugaring arrow commands \begin{code} module DsArrows ( dsProcExpr ) where #include "HsVersions.h" -import Match ( matchSimply ) -import DsUtils ( mkErrorAppDs, - mkCoreTupTy, mkCoreTup, selectSimpleMatchVarL, - mkTupleCase, mkBigCoreTup, mkTupleType, - mkTupleExpr, mkTupleSelector, - dsSyntaxTable, lookupEvidence ) +import Match +import DsUtils import DsMonad import HsSyn -import TcHsSyn ( hsLPatType ) +import TcHsSyn -- NB: The desugarer, which straddles the source and Core worlds, sometimes -- needs to see source types (newtypes etc), and sometimes not @@ -26,29 +24,24 @@ import TcHsSyn ( hsLPatType ) import {-# SOURCE #-} DsExpr ( dsExpr, dsLExpr, dsLocalBinds ) -import TcType ( Type, tcSplitAppTy, mkFunTy ) -import Type ( mkTyConApp, funArgTy ) +import TcType +import Type import CoreSyn -import CoreFVs ( exprFreeVars ) -import CoreUtils ( mkIfThenElse, bindNonRec, exprType ) - -import Id ( Id, idType ) -import Name ( Name ) -import PrelInfo ( pAT_ERROR_ID ) -import DataCon ( dataConWrapId ) -import TysWiredIn ( tupleCon ) -import BasicTypes ( Boxity(..) ) -import PrelNames ( eitherTyConName, leftDataConName, rightDataConName, - arrAName, composeAName, firstAName, - appAName, choiceAName, loopAName ) -import Util ( mapAccumL ) -import Outputable - -import HsUtils ( collectPatBinders, collectPatsBinders ) -import VarSet ( IdSet, mkVarSet, varSetElems, - intersectVarSet, minusVarSet, extendVarSetList, - unionVarSet, unionVarSets, elemVarSet ) -import SrcLoc ( Located(..), unLoc, noLoc ) +import CoreFVs +import CoreUtils + +import Id +import Name +import PrelInfo +import DataCon +import TysWiredIn +import BasicTypes +import PrelNames +import Util + +import HsUtils +import VarSet +import SrcLoc \end{code} \begin{code} diff --git a/compiler/deSugar/DsBinds.lhs b/compiler/deSugar/DsBinds.lhs index 85581c9aad..9fb2eaf37e 100644 --- a/compiler/deSugar/DsBinds.lhs +++ b/compiler/deSugar/DsBinds.lhs @@ -1,7 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[DsBinds]{Pattern-matching bindings (HsBinds and MonoBinds)} + +Pattern-matching bindings (HsBinds and MonoBinds) Handles @HsBinds@; those at the top level require different handling, in that the @Rec@/@NonRec@/etc structure is thrown away (whereas at @@ -15,36 +17,36 @@ module DsBinds ( dsTopLHsBinds, dsLHsBinds, decomposeRuleLhs, #include "HsVersions.h" - import {-# SOURCE #-} DsExpr( dsLExpr, dsExpr ) import {-# SOURCE #-} Match( matchWrapper ) import DsMonad -import DsGRHSs ( dsGuarded ) +import DsGRHSs import DsUtils import HsSyn -- lots of things import CoreSyn -- lots of things -import CoreUtils ( exprType, mkInlineMe, mkSCC ) - -import OccurAnal ( occurAnalyseExpr ) -import CostCentre ( mkAutoCC, IsCafCC(..) ) -import Id ( Id, DictId, idType, idName, mkLocalId, setInlinePragma ) -import Rules ( addIdSpecialisations, mkLocalRule ) -import Var ( TyVar, Var, isGlobalId, setIdNotExported ) +import CoreUtils + +import OccurAnal +import CostCentre +import Module +import Id +import Rules +import Var ( TyVar, Var ) import VarEnv -import Type ( mkTyVarTy, substTyWith ) -import TysWiredIn ( voidTy ) -import Module ( Module ) +import Type +import TysWiredIn import Outputable -import SrcLoc ( Located(..) ) -import Maybes ( catMaybes, orElse ) -import Bag ( bagToList ) -import BasicTypes ( Activation(..), InlineSpec(..), isAlwaysActive ) -import Monad ( foldM ) -import FastString ( mkFastString ) -import List ( (\\) ) +import SrcLoc +import Maybes +import Bag +import BasicTypes hiding ( TopLevel ) +import FastString import Util ( mapSnd ) + +import Control.Monad +import Data.List \end{code} %************************************************************************ diff --git a/compiler/deSugar/DsCCall.lhs b/compiler/deSugar/DsCCall.lhs index a041665f23..fca20df03d 100644 --- a/compiler/deSugar/DsCCall.lhs +++ b/compiler/deSugar/DsCCall.lhs @@ -1,7 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The AQUA Project, Glasgow University, 1994-1998 % -\section[DsCCall]{Desugaring C calls} + +Desugaring foreign calls \begin{code} module DsCCall @@ -19,48 +21,25 @@ import CoreSyn import DsMonad -import CoreUtils ( exprType, coreAltType, mkCoerce ) -import Id ( Id, mkWildId ) -import MkId ( mkFCallId, realWorldPrimId, mkPrimOpId ) -import Maybes ( maybeToBool ) -import ForeignCall ( ForeignCall(..), CCallSpec(..), CCallTarget(..), Safety, - CCallConv(..), CLabelString ) -import DataCon ( splitProductType_maybe, dataConSourceArity, dataConWrapId ) - -import TcType ( tcSplitIOType_maybe ) -import Type ( Type, isUnLiftedType, mkFunTys, mkFunTy, - tyVarsOfType, mkForAllTys, mkTyConApp, - isPrimitiveType, splitTyConApp_maybe, - splitRecNewType_maybe, splitForAllTy_maybe, - isUnboxedTupleType - ) -import Coercion ( Coercion, splitNewTypeRepCo_maybe, mkSymCoercion ) -import PrimOp ( PrimOp(..) ) -import TysPrim ( realWorldStatePrimTy, intPrimTy, - byteArrayPrimTyCon, mutableByteArrayPrimTyCon, - addrPrimTy - ) -import TyCon ( TyCon, tyConDataCons, tyConName ) -import TysWiredIn ( unitDataConId, - unboxedSingletonDataCon, unboxedPairDataCon, - unboxedSingletonTyCon, unboxedPairTyCon, - trueDataCon, falseDataCon, - trueDataConId, falseDataConId, - listTyCon, charTyCon, boolTy, - tupleTyCon, tupleCon - ) -import BasicTypes ( Boxity(..) ) -import Literal ( mkMachInt ) -import PrelNames ( Unique, hasKey, boolTyConKey, unitTyConKey, - int8TyConKey, int16TyConKey, int32TyConKey, - word8TyConKey, word16TyConKey, word32TyConKey - -- dotnet interop - , marshalStringName, unmarshalStringName - , marshalObjectName, unmarshalObjectName - , objectTyConName - ) -import VarSet ( varSetElems ) -import Constants ( wORD_SIZE) +import CoreUtils +import Id +import MkId +import Maybes +import ForeignCall +import DataCon + +import TcType +import Type +import Coercion +import PrimOp +import TysPrim +import TyCon +import TysWiredIn +import BasicTypes +import Literal +import PrelNames +import VarSet +import Constants import Outputable #ifdef DEBUG diff --git a/compiler/deSugar/DsExpr.lhs b/compiler/deSugar/DsExpr.lhs index a85f1001ec..4a5521c888 100644 --- a/compiler/deSugar/DsExpr.lhs +++ b/compiler/deSugar/DsExpr.lhs @@ -1,66 +1,59 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[DsExpr]{Matching expressions (Exprs)} + +Desugaring exporessions. \begin{code} module DsExpr ( dsExpr, dsLExpr, dsLocalBinds, dsValBinds, dsLit ) where #include "HsVersions.h" #if defined(GHCI) && defined(BREAKPOINT) -import Foreign.StablePtr ( newStablePtr, castStablePtrToPtr ) -import GHC.Exts ( Ptr(..), Int(..), addr2Int# ) -import IOEnv ( ioToIOEnv ) -import PrelNames ( breakpointJumpName, breakpointCondJumpName ) -import TysWiredIn ( unitTy ) -import TypeRep ( Type(..) ) -import TyCon ( isUnLiftedTyCon ) +import Foreign.StablePtr +import GHC.Exts +import IOEnv +import PrelNames +import TysWiredIn +import TypeRep +import TyCon #endif -import Match ( matchWrapper, matchSinglePat, matchEquations ) -import MatchLit ( dsLit, dsOverLit ) -import DsBinds ( dsLHsBinds, dsCoercion ) -import DsGRHSs ( dsGuarded ) -import DsListComp ( dsListComp, dsPArrComp ) -import DsUtils ( mkErrorAppDs, mkStringExpr, mkConsExpr, mkNilExpr, - extractMatchResult, cantFailMatchResult, matchCanFail, - mkCoreTupTy, selectSimpleMatchVarL, lookupEvidence, selectMatchVar ) -import DsArrows ( dsProcExpr ) +import Match +import MatchLit +import DsBinds +import DsGRHSs +import DsListComp +import DsUtils +import DsArrows import DsMonad #ifdef GHCI -- Template Haskell stuff iff bootstrapped -import DsMeta ( dsBracket ) +import DsMeta #endif import HsSyn -import TcHsSyn ( hsLPatType, mkVanillaTuplePat ) +import TcHsSyn -- NB: The desugarer, which straddles the source and Core worlds, sometimes --- needs to see source types (newtypes etc), and sometimes not --- So WATCH OUT; check each use of split*Ty functions. --- Sigh. This is a pain. - -import TcType ( tcSplitAppTy, tcSplitFunTys, tcTyConAppTyCon, - tcTyConAppArgs, isUnLiftedType, Type, mkAppTy ) -import Type ( splitFunTys, isUnboxedTupleType, mkFunTy ) +-- needs to see source types +import TcType +import Type import CoreSyn -import CoreUtils ( exprType, mkIfThenElse, bindNonRec ) - -import CostCentre ( mkUserCC ) -import Id ( Id, idType, idName, idDataCon ) -import PrelInfo ( rEC_CON_ERROR_ID ) -import DataCon ( DataCon, dataConWrapId, dataConFieldLabels, dataConInstOrigArgTys ) -import DataCon ( isVanillaDataCon ) -import TyCon ( FieldLabel, tyConDataCons ) -import TysWiredIn ( tupleCon ) -import BasicTypes ( RecFlag(..), Boxity(..), ipNameName ) -import PrelNames ( toPName, - returnMName, bindMName, thenMName, failMName, - mfixName ) -import SrcLoc ( Located(..), unLoc, getLoc, noLoc ) -import Util ( zipEqual, zipWithEqual ) -import Bag ( bagToList ) +import CoreUtils + +import CostCentre +import Id +import PrelInfo +import DataCon +import TyCon +import TysWiredIn +import BasicTypes +import PrelNames +import SrcLoc +import Util +import Bag import Outputable import FastString \end{code} diff --git a/compiler/deSugar/DsForeign.lhs b/compiler/deSugar/DsForeign.lhs index 462da0e051..ba19124f0c 100644 --- a/compiler/deSugar/DsForeign.lhs +++ b/compiler/deSugar/DsForeign.lhs @@ -1,9 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The AQUA Project, Glasgow University, 1998 % -\section[DsCCall]{Desugaring \tr{foreign} declarations} -Expanding out @foreign import@ and @foreign export@ declarations. +Desugaring foreign declarations (see also DsCCall). \begin{code} module DsForeign ( dsForeigns ) where @@ -13,48 +13,33 @@ import TcRnMonad -- temp import CoreSyn -import DsCCall ( dsCCall, mkFCall, boxResult, unboxArg, resultWrapper ) +import DsCCall import DsMonad -import HsSyn ( ForeignDecl(..), ForeignExport(..), LForeignDecl, - ForeignImport(..), CImportSpec(..) ) -import DataCon ( splitProductType_maybe ) -#ifdef DEBUG -import DataCon ( dataConSourceArity ) -import Type ( isUnLiftedType ) -#endif -import MachOp ( machRepByteWidth, MachRep(..) ) -import SMRep ( argMachRep, typeCgRep ) -import CoreUtils ( exprType, mkInlineMe ) -import Id ( Id, idType, idName, mkSysLocal, setInlinePragma ) -import Literal ( Literal(..), mkStringLit ) -import Module ( moduleNameFS, moduleName ) -import Name ( getOccString, NamedThing(..) ) -import Type ( repType, coreEqType ) -import Coercion ( mkUnsafeCoercion ) -import TcType ( Type, mkFunTys, mkForAllTys, mkTyConApp, - mkFunTy, tcSplitTyConApp_maybe, tcSplitIOType_maybe, - tcSplitForAllTys, tcSplitFunTys, tcTyConAppArgs, - isBoolTy - ) - -import BasicTypes ( Boxity(..) ) -import HscTypes ( ForeignStubs(..) ) -import ForeignCall ( ForeignCall(..), CCallSpec(..), - Safety(..), - CExportSpec(..), CLabelString, - CCallConv(..), ccallConvToInt, - ccallConvAttribute - ) -import TysWiredIn ( unitTy, tupleTyCon ) -import TysPrim ( addrPrimTy, mkStablePtrPrimTy, alphaTy, intPrimTy ) -import PrelNames ( stablePtrTyConName, newStablePtrName, bindIOName, - checkDotnetResName ) -import BasicTypes ( Activation( NeverActive ) ) -import SrcLoc ( Located(..), unLoc ) +import HsSyn +import DataCon +import MachOp +import SMRep +import CoreUtils +import Id +import Literal +import Module +import Name +import Type +import Coercion +import TcType + +import HscTypes +import ForeignCall +import TysWiredIn +import TysPrim +import PrelNames +import BasicTypes +import SrcLoc import Outputable -import Maybe ( fromJust, isNothing ) import FastString + +import Data.Maybe \end{code} Desugaring of @foreign@ declarations is naturally split up into diff --git a/compiler/deSugar/DsGRHSs.lhs b/compiler/deSugar/DsGRHSs.lhs index a8571f1e3b..93f4ead8f8 100644 --- a/compiler/deSugar/DsGRHSs.lhs +++ b/compiler/deSugar/DsGRHSs.lhs @@ -1,7 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[DsGRHSs]{Matching guarded right-hand-sides (GRHSs)} + +Matching guarded right-hand-sides (GRHSs) \begin{code} module DsGRHSs ( dsGuarded, dsGRHSs ) where @@ -11,20 +13,19 @@ module DsGRHSs ( dsGuarded, dsGRHSs ) where import {-# SOURCE #-} DsExpr ( dsLExpr, dsLocalBinds ) import {-# SOURCE #-} Match ( matchSinglePat ) -import HsSyn ( Stmt(..), HsExpr(..), GRHSs(..), GRHS(..), - LHsExpr, HsMatchContext(..), Pat(..) ) -import CoreSyn ( CoreExpr ) -import Var ( Id ) -import Type ( Type ) +import HsSyn +import CoreSyn +import Var +import Type import DsMonad import DsUtils -import Unique ( Uniquable(..) ) -import PrelInfo ( nON_EXHAUSTIVE_GUARDS_ERROR_ID ) -import TysWiredIn ( trueDataConId ) -import PrelNames ( otherwiseIdKey, hasKey ) -import Name ( Name ) -import SrcLoc ( unLoc, Located(..) ) +import Unique +import PrelInfo +import TysWiredIn +import PrelNames +import Name +import SrcLoc \end{code} @dsGuarded@ is used for both @case@ expressions and pattern bindings. diff --git a/compiler/deSugar/DsListComp.lhs b/compiler/deSugar/DsListComp.lhs index 2827fb688c..74091017c6 100644 --- a/compiler/deSugar/DsListComp.lhs +++ b/compiler/deSugar/DsListComp.lhs @@ -1,7 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[DsListComp]{Desugaring list comprehensions and array comprehensions} + +Desugaring list comprehensions and array comprehensions \begin{code} module DsListComp ( dsListComp, dsPArrComp ) where @@ -10,30 +12,26 @@ module DsListComp ( dsListComp, dsPArrComp ) where import {-# SOURCE #-} DsExpr ( dsLExpr, dsLocalBinds ) -import BasicTypes ( Boxity(..) ) +import BasicTypes import HsSyn -import TcHsSyn ( hsLPatType, mkVanillaTuplePat ) +import TcHsSyn import CoreSyn import DsMonad -- the monadery used in the desugarer import DsUtils -import DynFlags ( DynFlag(..), dopt ) -import StaticFlags ( opt_RulesOff ) -import CoreUtils ( exprType, mkIfThenElse ) -import Id ( idType ) -import Var ( Id ) -import Type ( mkTyVarTy, mkFunTys, mkFunTy, Type, - splitTyConApp_maybe ) -import TysPrim ( alphaTyVar ) -import TysWiredIn ( nilDataCon, consDataCon, trueDataConId, falseDataConId, - unitDataConId, unitTy, mkListTy, parrTyCon ) -import Match ( matchSimply ) -import PrelNames ( foldrName, buildName, replicatePName, mapPName, - filterPName, zipPName, crossPName ) -import PrelInfo ( pAT_ERROR_ID ) -import SrcLoc ( noLoc, unLoc ) -import Panic ( panic ) +import DynFlags +import StaticFlags +import CoreUtils +import Var +import Type +import TysPrim +import TysWiredIn +import Match +import PrelNames +import PrelInfo +import SrcLoc +import Panic \end{code} List comprehensions may be desugared in one of two ways: ``ordinary'' diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs index 6c04002558..d859d86b30 100644 --- a/compiler/deSugar/DsMeta.hs +++ b/compiler/deSugar/DsMeta.hs @@ -1,4 +1,7 @@ ----------------------------------------------------------------------------- +-- +-- (c) The University of Glasgow 2006 +-- -- The purpose of this module is to transform an HsExpr into a CoreExpr which -- when evaluated, returns a (Meta.Q Meta.Exp) computation analogous to the -- input HsExpr. We do this in the DsM monad, which supplies access to @@ -21,47 +24,45 @@ module DsMeta( dsBracket, import {-# SOURCE #-} DsExpr ( dsExpr ) -import MatchLit ( dsLit ) -import DsUtils ( mkListExpr, mkStringExpr, mkCoreTup, mkIntExpr ) +import MatchLit +import DsUtils import DsMonad import qualified Language.Haskell.TH as TH import HsSyn -import Class (FunDep) -import PrelNames ( rationalTyConName, integerTyConName, negateName ) -import OccName ( isDataOcc, isTvOcc, occNameString ) --- To avoid clashes with DsMeta.varName we must make a local alias for OccName.varName --- we do this by removing varName from the import of OccName above, making --- a qualified instance of OccName and using OccNameAlias.varName where varName --- ws previously used in this file. +import Class +import PrelNames +import OccName +-- To avoid clashes with DsMeta.varName we must make a local alias for +-- OccName.varName we do this by removing varName from the import of +-- OccName above, making a qualified instance of OccName and using +-- OccNameAlias.varName where varName ws previously used in this file. import qualified OccName -import Module ( Module, mkModule, moduleNameString, moduleName, - modulePackageId, mkModuleNameFS ) -import Id ( Id, mkLocalId ) -import OccName ( mkOccNameFS ) -import Name ( Name, mkExternalName, localiseName, nameOccName, nameModule, - isExternalName, getSrcLoc ) +import Module +import Id +import OccName +import Name import NameEnv -import Type ( Type, mkTyConApp ) -import TcType ( tcTyConAppArgs ) -import TyCon ( tyConName ) -import TysWiredIn ( parrTyCon ) +import Type +import TcType +import TyCon +import TysWiredIn import CoreSyn -import CoreUtils ( exprType ) -import SrcLoc ( noSrcLoc, unLoc, Located(..), SrcSpan, srcLocSpan ) -import PackageConfig ( thPackageId, packageIdString ) -import Unique ( mkPreludeTyConUnique, mkPreludeMiscIdUnique, getKey, Uniquable(..) ) -import BasicTypes ( isBoxed ) +import CoreUtils +import SrcLoc +import PackageConfig +import Unique +import BasicTypes import Outputable -import Bag ( bagToList, unionManyBags ) -import FastString ( unpackFS ) -import ForeignCall ( Safety(..), CCallConv(..), CCallTarget(..) ) +import Bag +import FastString +import ForeignCall -import Maybe ( catMaybes ) -import Monad ( zipWithM ) -import List ( sortBy ) +import Data.Maybe +import Control.Monad +import Data.List ----------------------------------------------------------------------------- dsBracket :: HsBracket Name -> [PendingSplice] -> DsM CoreExpr diff --git a/compiler/deSugar/DsMonad.lhs b/compiler/deSugar/DsMonad.lhs index 28ff62d21a..cbe182e44e 100644 --- a/compiler/deSugar/DsMonad.lhs +++ b/compiler/deSugar/DsMonad.lhs @@ -1,7 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[DsMonad]{@DsMonad@: monadery used in desugaring} + +@DsMonad@: monadery used in desugaring \begin{code} module DsMonad ( @@ -33,29 +35,28 @@ module DsMonad ( #include "HsVersions.h" import TcRnMonad -import CoreSyn ( CoreExpr ) -import HsSyn ( HsExpr, HsMatchContext, Pat ) -import TcIface ( tcIfaceGlobal ) -import RdrName ( GlobalRdrEnv ) -import HscTypes ( TyThing(..), TypeEnv, HscEnv(..), - tyThingId, tyThingTyCon, tyThingDataCon, mkPrintUnqualified ) -import Bag ( emptyBag, snocBag ) -import DataCon ( DataCon ) -import TyCon ( TyCon ) -import Id ( mkSysLocal, setIdUnique, Id ) -import Module ( Module ) -import Var ( TyVar, setTyVarUnique ) +import CoreSyn +import HsSyn +import TcIface +import RdrName +import HscTypes +import Bag +import DataCon +import TyCon +import Id +import Module +import Var import Outputable -import SrcLoc ( noSrcSpan, SrcSpan ) -import Type ( Type ) -import UniqSupply ( UniqSupply, uniqsFromSupply ) -import Name ( Name, nameOccName ) +import SrcLoc +import Type +import UniqSupply +import Name import NameEnv -import OccName ( occNameFS ) -import DynFlags ( DynFlags ) -import ErrUtils ( Messages, mkWarnMsg, mkErrMsg, - printErrorsAndWarnings, errorsFound ) -import DATA_IOREF ( newIORef, readIORef ) +import OccName +import DynFlags +import ErrUtils + +import Data.IORef infixr 9 `thenDs` \end{code} diff --git a/compiler/deSugar/DsUtils.lhs b/compiler/deSugar/DsUtils.lhs index e2334f3ad3..0552c2bd08 100644 --- a/compiler/deSugar/DsUtils.lhs +++ b/compiler/deSugar/DsUtils.lhs @@ -1,7 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[DsUtils]{Utilities for desugaring} + +Utilities for desugaring This module exports some utility functions of no great interest. @@ -40,44 +42,36 @@ import {-# SOURCE #-} Match ( matchSimply ) import {-# SOURCE #-} DsExpr( dsExpr ) import HsSyn -import TcHsSyn ( hsLPatType, hsPatType ) +import TcHsSyn import CoreSyn -import Constants ( mAX_TUPLE_SIZE ) +import Constants import DsMonad -import CoreUtils ( exprType, mkIfThenElse, mkCoerce, bindNonRec ) -import MkId ( iRREFUT_PAT_ERROR_ID, mkReboxingAlt, unwrapNewTypeBody ) -import Id ( idType, Id, mkWildId, mkTemplateLocals, mkSysLocal ) -import Var ( Var ) -import Name ( Name ) -import Literal ( Literal(..), mkStringLit, inIntRange, tARGET_MAX_INT ) -import TyCon ( isNewTyCon, tyConDataCons ) -import DataCon ( DataCon, dataConSourceArity, dataConTyCon, dataConTag ) -import Type ( mkFunTy, isUnLiftedType, Type, splitTyConApp, mkTyVarTy, - splitNewTyConApp ) -import Coercion ( mkUnsafeCoercion ) -import TysPrim ( intPrimTy ) -import TysWiredIn ( nilDataCon, consDataCon, - tupleCon, mkTupleTy, - unitDataConId, unitTy, - charTy, charDataCon, - intTy, intDataCon, - isPArrFakeCon ) -import BasicTypes ( Boxity(..) ) -import UniqSet ( mkUniqSet, minusUniqSet, isEmptyUniqSet ) -import UniqSupply ( splitUniqSupply, uniqFromSupply, uniqsFromSupply ) -import PrelNames ( unpackCStringName, unpackCStringUtf8Name, - plusIntegerName, timesIntegerName, smallIntegerDataConName, - lengthPName, indexPName ) +import CoreUtils +import MkId +import Id +import Var +import Name +import Literal +import TyCon +import DataCon +import Type +import Coercion +import TysPrim +import TysWiredIn +import BasicTypes +import UniqSet +import UniqSupply +import PrelNames import Outputable -import SrcLoc ( Located(..), unLoc ) -import Util ( isSingleton, zipEqual, sortWith ) -import ListSetOps ( assocDefault ) +import SrcLoc +import Util +import ListSetOps import FastString -import Data.Char ( ord ) +import Data.Char #ifdef DEBUG -import Util ( notNull ) -- Used in an assertion +import Util #endif \end{code} diff --git a/compiler/deSugar/Match.lhs b/compiler/deSugar/Match.lhs index b40bb53fb7..a31494e0a8 100644 --- a/compiler/deSugar/Match.lhs +++ b/compiler/deSugar/Match.lhs @@ -1,40 +1,40 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[Main_match]{The @match@ function} + +The @match@ function \begin{code} module Match ( match, matchEquations, matchWrapper, matchSimply, matchSinglePat ) where #include "HsVersions.h" -import DynFlags ( DynFlag(..), dopt ) +import DynFlags import HsSyn -import TcHsSyn ( mkVanillaTuplePat, hsPatType ) -import Check ( check, ExhaustivePat ) +import TcHsSyn +import Check import CoreSyn -import Literal ( Literal ) -import CoreUtils ( bindNonRec, exprType ) +import Literal +import CoreUtils import DsMonad -import DsBinds ( dsLHsBinds, dsCoercion ) -import DsGRHSs ( dsGRHSs ) +import DsBinds +import DsGRHSs import DsUtils -import Id ( idName, idType, Id ) -import DataCon ( DataCon ) -import MatchCon ( matchConFamily ) -import MatchLit ( matchLiterals, matchNPlusKPats, matchNPats, - tidyLitPat, tidyNPat, hsLitKey, hsOverLitKey ) -import PrelInfo ( pAT_ERROR_ID ) -import TcType ( Type ) -import Type ( splitFunTysN, coreEqType ) -import TysWiredIn ( consDataCon, mkListTy, unitTy, - tupleCon, parrFakeCon, mkPArrTy ) -import BasicTypes ( Boxity(..) ) -import ListSetOps ( equivClasses, runs ) -import SrcLoc ( unLoc, Located(..) ) -import Maybes ( isJust ) -import Util ( lengthExceeds, notNull ) -import Name ( Name ) +import Id +import DataCon +import MatchCon +import MatchLit +import PrelInfo +import TcType +import Type +import TysWiredIn +import BasicTypes +import ListSetOps +import SrcLoc +import Maybes +import Util +import Name import Outputable \end{code} diff --git a/compiler/deSugar/MatchCon.lhs b/compiler/deSugar/MatchCon.lhs index c4c38b163f..5233d59037 100644 --- a/compiler/deSugar/MatchCon.lhs +++ b/compiler/deSugar/MatchCon.lhs @@ -1,7 +1,9 @@ - +% +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[MatchCon]{Pattern-matching constructors} + +Pattern-matching constructors \begin{code} module MatchCon ( matchConFamily ) where @@ -10,19 +12,17 @@ module MatchCon ( matchConFamily ) where import {-# SOURCE #-} Match ( match ) -import HsSyn ( Pat(..), LPat, HsConDetails(..), HsRecField(..) ) -import DsBinds ( dsLHsBinds ) -import DataCon ( DataCon, dataConInstOrigArgTys, dataConEqSpec, - dataConFieldLabels, dataConSourceArity ) -import TcType ( tcTyConAppArgs ) -import Type ( mkTyVarTys ) +import HsSyn +import DsBinds +import DataCon +import TcType +import Type import CoreSyn import DsMonad import DsUtils -import Id ( Id, idName ) -import Type ( Type ) -import SrcLoc ( unLoc, Located(..) ) +import Id +import SrcLoc import Outputable \end{code} diff --git a/compiler/deSugar/MatchLit.lhs b/compiler/deSugar/MatchLit.lhs index 3751f95a83..d7e8ba64d8 100644 --- a/compiler/deSugar/MatchLit.lhs +++ b/compiler/deSugar/MatchLit.lhs @@ -1,7 +1,9 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section[MatchLit]{Pattern-matching literal patterns} + +Pattern-matching literal patterns \begin{code} module MatchLit ( dsLit, dsOverLit, hsLitKey, hsOverLitKey, @@ -17,24 +19,23 @@ import DsMonad import DsUtils import HsSyn -import Id ( Id, idType ) +import Id import CoreSyn -import TyCon ( tyConDataCons ) -import DataCon ( DataCon ) -import TcType ( tcSplitTyConApp, isIntegerTy, isIntTy, - isFloatTy, isDoubleTy, isStringTy ) -import Type ( Type ) -import PrelNames ( ratioTyConKey ) -import TysWiredIn ( stringTy, consDataCon, intDataCon, floatDataCon, doubleDataCon ) -import PrelNames ( eqStringName ) -import Unique ( hasKey ) -import Literal ( mkMachInt, Literal(..) ) -import SrcLoc ( noLoc ) -import Ratio ( numerator, denominator ) -import SrcLoc ( Located(..), unLoc ) +import TyCon +import DataCon +import TcType +import Type +import PrelNames +import TysWiredIn +import PrelNames +import Unique +import Literal +import SrcLoc +import Ratio +import SrcLoc import Outputable -import Util ( mapAndUnzip ) -import FastString ( lengthFS, unpackFS ) +import Util +import FastString \end{code} %************************************************************************ diff --git a/compiler/deSugar/deSugar.tex b/compiler/deSugar/deSugar.tex deleted file mode 100644 index 02cb285742..0000000000 --- a/compiler/deSugar/deSugar.tex +++ /dev/null @@ -1,23 +0,0 @@ -\documentstyle{report} -\input{lit-style} - -\begin{document} -\centerline{{\Large{deSugar}}} -\tableofcontents - -\input{Desugar} % {@deSugar@: the main function} -\input{DsBinds} % {Pattern-matching bindings (HsBinds and MonoBinds)} -\input{DsGRHSs} % {Matching guarded right-hand-sides (GRHSs)} -\input{DsExpr} % {Matching expressions (Exprs)} -\input{DsHsSyn} % {Haskell abstract syntax---added things for desugarer} -\input{DsListComp} % {Desugaring list comprehensions} -\input{DsMonad} % {@DsMonad@: monadery used in desugaring} -\input{DsUtils} % {Utilities for desugaring} -\input{Check} % {Module @Check@ in @deSugar@} -\input{Match} % {The @match@ function} -\input{MatchCon} % {Pattern-matching constructors} -\input{MatchLit} % {Pattern-matching literal patterns} -\input{DsForeign} % {Desugaring \tr{foreign} declarations} -\input{DsCCall} % {Desugaring \tr{_ccall_}s and \tr{_casm_}s} - -\end{document} |
