views:

191

answers:

2

I've been given this question in a tutorial, and I really don't know how to go about it.

How must g and h be defined in terms of p and f in order to ensure that
filter p . map f = map g . filter h
always holds?

Any pointers in the right direction would be greatly appreciated.

+7  A: 

It is clear that f :: a -> b and p :: b -> Bool. Since we cannot make any other assumptions about f and g, one will have to define

h = p . f
g = f

Now h :: a -> Bool and g :: a -> b.

Stephan202
+3  A: 

Think about types.

f :: a -> b
g :: a -> b
p :: b -> Bool
h :: a -> Bool
Dave Hinton