artemohanjanyan/university

Normalization doesn't work

Opened this issue · 0 comments

$ normalize
(\a.\x.a) x
\x'.x
$ normalize
(\a.\x.\x.a) x
normalize: src/Simple/Reduction.hs:82:5-70: Irrefutable pattern failed for pattern Right newExpr

At first sight the problem is in rename' function:

rename' act dict (Lambda var expr)
        | Map.member var dict = Lambda newVar $ rename' (Map.insert var newVar act) (Map.delete var dict) expr
        | Map.member var act  = Lambda var    $ rename' (Map.delete var act)        dict                  expr
        | otherwise           = Lambda var    $ rename' act                         dict                  expr

Seems, you should not delete bound variable from dict, or should replace it with actual value on second stage of the pattern matching above.