... | ... | @@ -31,4 +31,42 @@ Status: ok |
|
|
{-# LANGUAGE BangPatterns #-}moduleFoowherefoo::Int->(Int,Int)->(Int,Int)foo n p
|
|
|
| even (n + uncurry (+) p), n /=0= foo (n -1) p
|
|
|
| n ==0=(1,2)| otherwise = p
|
|
|
```
|
|
|
|
|
|
### strict_field.hs
|
|
|
|
|
|
|
|
|
This one needs a correct handling of strict constructor fields. Inspired by `nofib/imaginary/x2n1`.
|
|
|
|
|
|
|
|
|
Status: ok
|
|
|
|
|
|
```
|
|
|
{-# LANGUAGE BangPatterns #-}moduleFoowheredataC a =C!a !a
|
|
|
|
|
|
pow::CDouble->Int->CDoublepow!_0=C01pow!c 1= c
|
|
|
pow c n
|
|
|
| even n =let d = pow c (div n 2)in mul d d
|
|
|
| otherwise = mul c (pow c (n -1))mul::CDouble->CDouble->CDoublemul(C a b)(C d e)=C(a*d-b*e)(a*e+b*d)
|
|
|
```
|
|
|
|
|
|
### strict_field1.hs
|
|
|
|
|
|
|
|
|
This is similar to `strict_field.hs`, but needs a more aggressive worker-wrapper.
|
|
|
|
|
|
|
|
|
Status: not ok. Currently the worker has the type `Double -> Double -> Int# -> (# Double, Double #)`, rather than the desired `Double# -> Double# -> Int# -> (# Double#, Double# #)`.
|
|
|
|
|
|
|
|
|
Changing CPR analysis alone wouldn't help here. We need to give the function a better strictness as well.
|
|
|
|
|
|
```
|
|
|
moduleFoo(pow)wheredataC a =C!a !a
|
|
|
|
|
|
pow::CDouble->Int->CDoublepow x y
|
|
|
| even y = pow (x `mul` x)(y `quot`2)| y ==1= x
|
|
|
| otherwise = pow (x `mul` x)((y -1)`quot`2)`mul` x
|
|
|
|
|
|
mul::CDouble->CDouble->CDoublemul(C a b)(C d e)=C(a*d-b*e)(a*e+b*d)
|
|
|
``` |
|
|
\ No newline at end of file |