on master help sign in
Normalise less when unifying

This doesn't gain us a huge amount, but can make display of patterns better when generating case splits

commit4a4548e10368ff19e2423b119780d3078544a28f authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSun 10 Apr 2016, 22:45 (11 years ago) parent2dfba31
6 files changed+24−10
idris.cabal+4 src/Idris/Core/Unify.hs+8−10 test/interactive013/expected+4 test/interactive013/input+1 test/interactive013/interactive013.idr+4 test/interactive013/run+3
idris.cabal+4
@@ -589,6 +589,10 @@ Extra-source-files:
589589 test/interactive012/input
590590 test/interactive012/run
591591 test/interactive012/*.idr
592+ test/interactive013/expected
593+ test/interactive013/input
594+ test/interactive013/run
595+ test/interactive013/*.idr
592596
593597 test/io001/run
594598 test/io001/*.idr
src/Idris/Core/Unify.hs+8−10
@@ -529,13 +529,19 @@ unify ctxt env (topx, xfrom) (topy, yfrom) inj holes usersupp from =
529529 (do hf <- un' env True bnames fx fy
530530 let ax' = hnormalise hf ctxt env (substNames hf ax)
531531 let ay' = hnormalise hf ctxt env (substNames hf ay)
532− ha <- un' env False bnames ax' ay'
532+ -- Don't normalise if we don't have to
533+ ha <- uplus (un' env False bnames (substNames hf ax)
534+ (substNames hf ay))
535+ (un' env False bnames ax' ay')
533536 sc 1
534537 combine env bnames hf ha)
535538 (do ha <- un' env False bnames ax ay
536539 let fx' = hnormalise ha ctxt env (substNames ha fx)
537540 let fy' = hnormalise ha ctxt env (substNames ha fy)
538− hf <- un' env False bnames fx' fy'
541+ -- Don't normalise if we don't have to
542+ hf <- uplus (un' env False bnames (substNames ha fx)
543+ (substNames ha fy))
544+ (un' env False bnames fx' fy')
539545 sc 1
540546 combine env bnames hf ha)
541547 | otherwise = unifyTmpFail appx appy
@@ -551,14 +557,6 @@ unify ctxt env (topx, xfrom) (topy, yfrom) inj holes usersupp from =
551557 = unifyFail appx appy
552558 checkHeads _ _ = return []
553559
554− unArgs as [] [] = return as
555− unArgs as (x : xs) (y : ys)
556− = do let x' = hnormalise as ctxt env (substNames as x)
557− let y' = hnormalise as ctxt env (substNames as y)
558− as' <- un' env False bnames x' y'
559− vs <- combine env bnames as as'
560− unArgs vs xs ys
561−
562560 numArgs tm = let (f, args) = unApply tm in length args
563561
564562 metavarApp tm = let (f, args) = unApply tm in
test/interactive013/expectednew file+4
@@ -0,0 +1,4 @@
1+gcd aa (aa + (S y)) (CmpLT y) = ?gcd_rhs_1
2+gcd bb bb CmpEQ = ?gcd_rhs_2
3+gcd (bb + (S x)) bb (CmpGT x) = ?gcd_rhs_3
4+
test/interactive013/inputnew file+1
@@ -0,0 +1 @@
1+:cs 3 cc
test/interactive013/interactive013.idrnew file+4
@@ -0,0 +1,4 @@
1+
2+gcd : (x : Nat) -> (y : Nat) -> CmpNat x y -> Nat
3+gcd aa bb cc = ?gcd_rhs
4+
test/interactive013/runnew file+3
@@ -0,0 +1,3 @@
1+#!/usr/bin/env bash
2+${IDRIS:-idris} --quiet interactive013.idr < input
3+rm -f *.ibc