My guess — by finding a member that satisfies a predicate, if it's at all possible, and any member if the predicate is const False. It's actually pretty awesome.
Naïvely, a set implemented as a predicate determining membership?
I don't understand, how does
(a -> Bool) -> a
model a set?
Thanks
Siddharth
Note that a concrete set "concretizes" anything it touches. Don't take
unions of these sets, though, it'll just be a mess.
Won't a union just be the same as intersection but using || instead of && ?
-Jan-Willem Maessen
union (Pred p) (Concrete s) = Pred (\k -> p k || member k s)
What you can not do, of course, is enumerate and fold these sets.
Set a = Maybe ((a -> Bool) -> a)
It has unions, intersections and a Monad instance and can represent infinite sets. If the base type has an Ord instance, the set can be enumerated. If the base type has an Eq instance, so has (Set a). Some functions usually implemented using Foldable are also possible, e.g. minimum and maximum.
Caveat: Performance can be poor, depending on how the function inside the set was defined.
Cheers,
Olaf
[1] http://hackage.haskell.org/package/infinite-search
_______________________________________________
Haskell-Cafe mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
--
Sending this from my phone, please excuse any typos!
_______________________________________________
Haskell-Cafe mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
--
brandon s allbery kf8nh
_______________________________________________
Haskell-Cafe mailing list
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
Only members subscribed via the mailman list are allowed to post.