7 Jul
2004
7 Jul
'04
6:45 p.m.
On Wed, Jul 07, 2004 at 01:18:54PM +0100, Graham Klyne wrote:
There's a pattern of higher-order function usage I find myself repeatedly wanting to use, exemplified by the following:
[[ -- combineTest :: (Bool->Bool->Bool) -> (a->Bool) -> (a->Bool) -> (a->Bool) combineTest :: (b->c->d) -> (a->b) -> (a->c) -> a -> d combineTest c t1 t2 = \a -> c (t1 a) (t2 a)
(.&.) :: (a->Bool) -> (a->Bool) -> (a->Bool) (.&.) = combineTest (&&)
This can be seen as liftM2 on the reader monad ((->) r): (.&.) = liftM2 (&&) t1 = (>0) .&. (<=4) ans = t1 3 == True Andrew