ddc-core-simpl-0.4.3.1: Disciplined Disciple Compiler code transformations.

Safe HaskellSafe
LanguageHaskell98

DDC.Core.Transform.Rewrite.Match

Contents

Description

Create substitution to make (subst template) == target

Synopsis

Substitutions

type SubstInfo a n = (Map n (Exp a n), Map n (Type n)) Source #

Value and type substition.

emptySubstInfo :: SubstInfo a n Source #

An empty substition info.

Matching

match Source #

Arguments

:: (Show a, Show n, Ord n) 
=> SubstInfo a n

Current substitution

-> Set n

Variables we're interested in

-> Exp a n

Template expression.

-> Exp a n

Target expression.

-> Maybe (SubstInfo a n) 

Create substitution to make (subst template) == target Does not handle higher-order templates (ie ones with binders)

@ match emptySubstInfo (Set.fromList [r1, r2, s]) (stream [r1] (unstream [r2] s)) (stream [R0] (someStream 23))

> { r1 |-> R0#, r2 |-> R1, s |-> someStream 23 }

@