<commit_before>%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section[CoreSyn]{A data type for the Haskell compiler midsection}

\begin{code}
module CoreSyn (
	Expr(..), Alt, Bind(..), AltCon(..), Arg, Note(..),
	CoreExpr, CoreAlt, CoreBind, CoreArg, CoreBndr,
	TaggedExpr, TaggedAlt, TaggedBind, TaggedArg, TaggedBndr(..),

	mkLets, mkLams, 
	mkApps, mkTyApps, mkValApps, mkVarApps,
	mkLit, mkIntLitInt, mkIntLit, 
	mkConApp, 
	varToCoreExpr,

	isTyVar, isId, 
	bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts, 
	collectBinders, collectTyBinders, collectValBinders, collectTyAndValBinders,
	collectArgs, 
	coreExprCc,
	flattenBinds, 

	isValArg, isTypeArg, valArgCount, valBndrCount, isRuntimeArg, isRuntimeVar,

	-- Unfoldings
	Unfolding(..),	UnfoldingGuidance(..), 	-- Both abstract everywhere but in CoreUnfold.lhs
	noUnfolding, mkOtherCon,
	unfoldingTemplate, maybeUnfoldingTemplate, otherCons, 
	isValueUnfolding, isEvaldUnfolding, isCheapUnfolding, isCompulsoryUnfolding,
	hasUnfolding, hasSomeUnfolding, neverUnfold,

	-- Seq stuff
	seqRules, seqExpr, seqExprs, seqUnfolding,

	-- Annotated expressions
	AnnExpr, AnnExpr'(..), AnnBind(..), AnnAlt, 
	deAnnotate, deAnnotate', deAnnAlt, collectAnnBndrs,

	-- Core rules
	CoreRules(..), 	-- Representation needed by friends
	CoreRule(..),	-- CoreSubst, CoreTidy, CoreFVs, PprCore only
	IdCoreRule,
	RuleName,
	emptyCoreRules, isEmptyCoreRules, rulesRhsFreeVars, rulesRules,
	isBuiltinRule, ruleName
    ) where

#include "HsVersions.h"

import CmdLineOpts	( opt_RuntimeTypes )
import CostCentre	( CostCentre, noCostCentre )
import Var		( Var, Id, TyVar, isTyVar, isId )
import Type		( Type, mkTyVarTy, seqType )
import Literal	        ( Literal, mkMachInt )
import DataCon		( DataCon, dataConWorkId )
import BasicTypes	( Activation )
import VarSet
import FastString
import Outputable
\end{code}

%************************************************************************
%*									*
\subsection{The main data types}
%*									*
%************************************************************************

These data types are the heart of the compiler

\begin{code}
infixl 8 `App`	-- App brackets to the left

data Expr b	-- "b" for the type of binders, 
  = Var	  Id
  | Lit   Literal
  | App   (Expr b) (Arg b)
  | Lam   b (Expr b)
  | Let   (Bind b) (Expr b)
  | Case  (Expr b) b [Alt b]  	-- Binder gets bound to value of scrutinee
				-- DEFAULT case must be *first*, if it occurs at all
  | Note  Note (Expr b)
  | Type  Type			-- This should only show up at the top
				-- level of an Arg

type Arg b = Expr b		-- Can be a Type

type Alt b = (AltCon, [b], Expr b)	-- (DEFAULT, [], rhs) is the default alternative

data AltCon = DataAlt DataCon
	    | LitAlt  Literal
	    | DEFAULT
	 deriving (Eq, Ord)

data Bind b = NonRec b (Expr b)
	      | Rec [(b, (Expr b))]

data Note
  = SCC CostCentre<commit_msg>[project @ 2003-07-23 13:08:22 by simonpj] Comment case-alternative invariants<commit_after>%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
\section[CoreSyn]{A data type for the Haskell compiler midsection}

\begin{code}
module CoreSyn (
	Expr(..), Alt, Bind(..), AltCon(..), Arg, Note(..),
	CoreExpr, CoreAlt, CoreBind, CoreArg, CoreBndr,
	TaggedExpr, TaggedAlt, TaggedBind, TaggedArg, TaggedBndr(..),

	mkLets, mkLams, 
	mkApps, mkTyApps, mkValApps, mkVarApps,
	mkLit, mkIntLitInt, mkIntLit, 
	mkConApp, 
	varToCoreExpr,

	isTyVar, isId, 
	bindersOf, bindersOfBinds, rhssOfBind, rhssOfAlts, 
	collectBinders, collectTyBinders, collectValBinders, collectTyAndValBinders,
	collectArgs, 
	coreExprCc,
	flattenBinds, 

	isValArg, isTypeArg, valArgCount, valBndrCount, isRuntimeArg, isRuntimeVar,

	-- Unfoldings
	Unfolding(..),	UnfoldingGuidance(..), 	-- Both abstract everywhere but in CoreUnfold.lhs
	noUnfolding, mkOtherCon,
	unfoldingTemplate, maybeUnfoldingTemplate, otherCons, 
	isValueUnfolding, isEvaldUnfolding, isCheapUnfolding, isCompulsoryUnfolding,
	hasUnfolding, hasSomeUnfolding, neverUnfold,

	-- Seq stuff
	seqRules, seqExpr, seqExprs, seqUnfolding,

	-- Annotated expressions
	AnnExpr, AnnExpr'(..), AnnBind(..), AnnAlt, 
	deAnnotate, deAnnotate', deAnnAlt, collectAnnBndrs,

	-- Core rules
	CoreRules(..), 	-- Representation needed by friends
	CoreRule(..),	-- CoreSubst, CoreTidy, CoreFVs, PprCore only
	IdCoreRule,
	RuleName,
	emptyCoreRules, isEmptyCoreRules, rulesRhsFreeVars, rulesRules,
	isBuiltinRule, ruleName
    ) where

#include "HsVersions.h"

import CmdLineOpts	( opt_RuntimeTypes )
import CostCentre	( CostCentre, noCostCentre )
import Var		( Var, Id, TyVar, isTyVar, isId )
import Type		( Type, mkTyVarTy, seqType )
import Literal	        ( Literal, mkMachInt )
import DataCon		( DataCon, dataConWorkId )
import BasicTypes	( Activation )
import VarSet
import FastString
import Outputable
\end{code}

%************************************************************************
%*									*
\subsection{The main data types}
%*									*
%************************************************************************

These data types are the heart of the compiler

\begin{code}
infixl 8 `App`	-- App brackets to the left

data Expr b	-- "b" for the type of binders, 
  = Var	  Id
  | Lit   Literal
  | App   (Expr b) (Arg b)
  | Lam   b (Expr b)
  | Let   (Bind b) (Expr b)
  | Case  (Expr b) b [Alt b]  	-- Binder gets bound to value of scrutinee
	-- Invariant: the list of alternatives is ALWAYS EXHAUSTIVE
	-- Invariant: the DEFAULT case must be *first*, if it occurs at all
  | Note  Note (Expr b)
  | Type  Type			-- This should only show up at the top
				-- level of an Arg

type Arg b = Expr b		-- Can be a Type

type Alt b = (AltCon, [b], Expr b)	-- (DEFAULT, [], rhs) is the default alternative

data AltCon = DataAlt DataCon
	    | LitAlt  Literal
	    | DEFAULT
	 deriving (Eq, Ord)

data Bind b = NonRec b (Expr b)
	      | Rec [(b, (Expr b))]

data Note
  = SCC CostCentre
{'fraction_non_alphanumeric': 0.14918809201623817, 'fraction_numerical': 0.005412719891745603, 'mean_word_length': 4.040920716112532, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2114253', 'n_tokens_mistral': 2218, 'n_tokens_neox': 2060, 'n_words': 616}