X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=clash%2FCLasH%2FNormalize%2FNormalizeTypes.hs;h=506633de65e569548787d8c8deca83d3cc814755;hb=db856c9442e721689a566c6f91e8763f075e7da5;hp=4e98709eed26c2bf07dbbf5339014957cd44910d;hpb=04f836932ad17dd557af0ba388a12d2b74c1e7d7;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/clash/CLasH/Normalize/NormalizeTypes.hs b/clash/CLasH/Normalize/NormalizeTypes.hs index 4e98709..506633d 100644 --- a/clash/CLasH/Normalize/NormalizeTypes.hs +++ b/clash/CLasH/Normalize/NormalizeTypes.hs @@ -21,14 +21,36 @@ data CoreContext = AppFirst -- ^ The expression is the first | AppSecond -- ^ The expression is the second -- argument of an application -- (i.e., something is applied to it) - | LetBinding -- ^ The expression is bound in a + | LetBinding [CoreSyn.CoreBndr] + -- ^ The expression is bound in a -- (recursive or non-recursive) let -- expression. - | LetBody -- ^ The expression is the body of a + | LetBody [CoreSyn.CoreBndr] + -- ^ The expression is the body of a -- let expression - | LambdaBody -- ^ The expression is the body of a + | LambdaBody CoreSyn.CoreBndr + -- ^ The expression is the body of a -- lambda abstraction | Other -- ^ Another context deriving (Eq, Show) -- | Transforms a CoreExpr and keeps track if it has changed. type Transform = [CoreContext] -> CoreSyn.CoreExpr -> TransformMonad CoreSyn.CoreExpr + +-- Predicates for each of the context types +is_appfirst_ctx, is_appsecond_ctx, is_letbinding_ctx, is_letbody_ctx, is_lambdabody_ctx + :: CoreContext -> Bool + +is_appfirst_ctx AppFirst = True +is_appfirst_ctx _ = False + +is_appsecond_ctx AppSecond = True +is_appsecond_ctx _ = False + +is_letbinding_ctx (LetBinding _) = True +is_letbinding_ctx _ = False + +is_letbody_ctx (LetBody _) = True +is_letbody_ctx _ = False + +is_lambdabody_ctx (LambdaBody _) = True +is_lambdabody_ctx _ = False