Open nicolabotta opened 6 years ago
As it turns out, the problem is the implementation of otimes
. Replacing
> otimes e f p = x :: xs where
> x = e (\ x' => overline (f x') (\ xs' => p (x' :: xs')))
> xs = f x (\ xs' => p (x :: xs'))
with
> otimes e f p = let x = e (\ x' => overline (f x') (\ xs' => p (x' :: xs'))) in
> let xs = f x (\ xs' => p (x :: xs')) in
> x :: xs
makes the code run in times comparable with those of the Haskell implementation. The problem is that, with where
, the computation of x
is delegated to a global function that is then called three times: two times in the computation of xs
and one time in the computation of x :: xs
.
Thanks to Edwin for spotting the problem! I am not going to close the issue for the time being as I am not sure that this is the intended behavior.
The program
can be compiled under 1.3.0-git:02bfaac6f with
idris -O3 --warnreach --allow-capitalized-pattern-variables Main.lidr -o Main
. The executable runs more or less instantaneosly:But replacing line 33 with
yields execution times of about 3 seconds
and
execution times of about one and a half minutes
Running with
takes about 13 minutes
and if one increases the length of the
argsup
argument above about 10, the Idris program keeps on running for days, perhaps months! Notice that the corresponding Haskell programexecutes in slightly more than quadratic time in the lengths of the
argsup
argument for lengths up to 400:What do you expect to be the complexity of the computation in the length of the
argsup
argument? What is going wrong in the Idris execution? Is there a way to get acceptable execution times in Idris? Or to understand what makes the Idris code so inefficient? Thanks, Nicola