`seq` by partially applied functions

Say I have the following:

f :: a -> b -> c
g :: b -> c
g = f 10

Now let's say, factually:

f x y = f1 x + y

Will be:

g `seq` ...

really appreciate f1 10, so later on at startup

g 9

is this just a simple addition?

If not, is there a way to β€œevaluate” parts of a partially applied function?

I am looking for a universal solution that does not depend on how fand work g.

+5
source share
2 answers

seq not deep:

Prelude> let f1 = undefined
Prelude> let f = \x -> \y -> f1 x + y
Prelude> let g = f 10
Prelude> g `seq` 1
1
Prelude> g 9
*** Exception: Prelude.undefined
Prelude>

I would look at Control.DeepSeq: http://hackage.haskell.org/packages/archive/deepseq/1.2.0.1/doc/html/Control-DeepSeq.html

+3
source

, , f y. f1 x g, f :

f x = let z = f1 x in \y -> z + y

, - f1 x g. g `seq` ... f1 x, :

f x = let z = f1 x in z `seq` (\y -> z + y)
+9

All Articles