Change elaboration of lets

Elaborate the scope of a let without the computational behaviour,
meaning that `let x = v in e` is equivalent to `(\x => e) v`. This makes
things more consistent (in that let bindings already don't propagate
inside case or with blocks) at the cost of not being able to rely on the
computational behaviour in types. More importantly, it removes a
significant potential source of slowness.

Fixes #58

If you need the computational behaviour, you can use a local function
definition instead.
This commit is contained in:
Edwin Brady 2019-07-28 13:40:51 +01:00
parent d5409ac2d0
commit f1a4e0c09d
6 changed files with 26 additions and 3 deletions

View File

@ -58,8 +58,8 @@ updatePaths
Just path => do traverse addLibDir (map trim (split (==pathSep) path))
pure ()
Nothing => pure ()
-- BLODWEN_PATH goes first so that it overrides this if there's
-- any conflicts. In particular, that means that setting BLODWEN_PATH
-- IDRIS2_PATH goes first so that it overrides this if there's
-- any conflicts. In particular, that means that setting IDRIS2_PATH
-- for the tests means they test the local version not the installed
-- version
addPkgDir "prelude"

View File

@ -181,7 +181,7 @@ checkLet rigc_in elabinfo nest env fc rigl n nTy nVal scope expty
nest env nVal (Just (gnf env tyv))
pure (fst c, snd c, Rig1)
e => throw e)
let env' : Env Term (n :: _) = Let rigb valv tyv :: env
let env' : Env Term (n :: _) = Lam rigb Explicit tyv :: env
let nest' = weaken (dropName n nest)
expScope <- weakenExp env' expty
(scopev, gscopet) <-

View File

@ -42,6 +42,7 @@ idrisTests
"lazy001",
"linear001", "linear002", "linear003", "linear004", "linear005",
"linear006", "linear007",
"perf001",
"perror001", "perror002", "perror003", "perror004", "perror005",
"perror006",
"record001", "record002",

View File

@ -0,0 +1,18 @@
import Data.Vect
test : Vect 33 Int -> IO Int
test bytes_list = do
let int1 = (index 0 bytes_list * 8) +
(index 1 bytes_list * 4) +
(index 2 bytes_list * 2) + (index 3 bytes_list)
let int2 = (index 4 bytes_list * 8) + (index 5 bytes_list * 4) + (index 6 bytes_list * 2) + (index 7 bytes_list)
let int3 = (index 8 bytes_list * 8) + (index 9 bytes_list * 4) + (index 10 bytes_list * 2) + (index 11 bytes_list)
let int4 = (index 12 bytes_list * 8) + (index 13 bytes_list * 4) + (index 14 bytes_list * 2) + (index 15 bytes_list)
let int5 = (index 12 bytes_list * 8) + (index 13 bytes_list * 4) + (index 14 bytes_list * 2) + (index 15 bytes_list)
let int6 = (index 12 bytes_list * 8) + (index 13 bytes_list * 4) + (index 14 bytes_list * 2) + (index 15 bytes_list)
let int7 = (index 12 bytes_list * 8) + (index 13 bytes_list * 4) + (index 14 bytes_list * 2) + (index 15 bytes_list)
let int8 = (index 12 bytes_list * 8) + (index 13 bytes_list * 4) + (index 14 bytes_list * 2) + (index 15 bytes_list)
let int9 = (index 12 bytes_list * 8) + (index 13 bytes_list * 4) + (index 14 bytes_list * 2) + (index 15 bytes_list)
let int10 = (index 12 bytes_list * 8) + (index 13 bytes_list * 4) + (index 14 bytes_list * 2) + (index 15 bytes_list)
pure int1

View File

@ -0,0 +1 @@
1/1: Building Big (Big.idr)

3
tests/idris2/perf001/run Executable file
View File

@ -0,0 +1,3 @@
$1 --check Big.idr
rm -rf build