[Haskell-beginners] How to show a predicate

Kostiantyn Rybnikov k-bx at k-bx.com
Tue Dec 29 07:21:52 UTC 2015


You can store both values, a function and a string representation, in a
predicate:

data Predicate = Predicate (a -> Bool) String

And write corresponding Show instance to show string.

On Wed, Dec 23, 2015 at 2:55 PM, martin <martin.drautzburg at web.de> wrote:

> Hello all,
>
> in my program, I do stuff with predicates (a->Bool). For the most part
> this representation is just fine, but at the very
> end I need to convert a resulting predicate into a String so I can write
> it to a file.
>
> Wenn I represent my predicates as Lists or Sets, then this is doable and I
> am tempted to do it this way. The only other
> option I could come up with was to have a representation of "everything",
> which would in my case be large (10^8) but
> finite. Then I could construct a List or a Set at the very end, as [x |
> x<-everything, p x] without having explicit sets
> in the intermediate steps.
>
> I cannot see any other option, but I thought I better ask.
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151229/58293418/attachment.html>


More information about the Beginners mailing list