-
Notifications
You must be signed in to change notification settings - Fork 635
Open
Description
The following program
> module Main
> n : Nat
> n = 100
> nats : Vect Nat n
> nats = fromList [1..n]
> main : IO ()
> main = putStrLn (show (cast n))
executes in constant time in n as one would expect. Compilation, however, takes exponential time:
n user time
100 0m0.728s
200 0m1.304s
400 0m3.352s
800 0m14.737s
1600 1m30.258s
In fact, at n = 3200, compilation virtually stalls (on my laptop) after having eaten up the whole memory (8GB). Notice that replacing
> nats : Vect Nat n
> nats = fromList [1..n]
with
> nats : List Nat
> nats = [1..n]
yields constant compile times. Is it possible to construct vectors of natural numbers of length n in at most linear time (in n) ?