Simplifying double-nested forall

14 views
Skip to first unread message

Chris Marshall

unread,
Feb 16, 2012, 12:58:21 PM2/16/12
to sca...@googlegroups.com
I have a collection of Xs, M[X], a function which, for each X, produces an N[Y], and predicate over Y. M and N are foldable, functors and monads

M[X]
f: X => N[Y]
g: Y => Boolean

I wish to know whether the resulting M[N[Boolean]] is all true but obviously without evaluating any more than necessary; so

xs all (x => f(x) all (y => g(y)))  

Is there a more scalaz-y way of doing this? I was wondering if I might be able to do something with the fact that f could be kleisli-fied and got this far:

(kleisli(f) map g) =<< xs

but this requires M = N and does no lazy evaluation (I end up with M[Boolean])

Chris



Reply all
Reply to author
Forward
0 new messages