Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  How to show a predicate (Kostiantyn Rybnikov)
   2. Re:  explaining effects (Alexander Berntsen)


----------------------------------------------------------------------

Message: 1
Date: Tue, 29 Dec 2015 09:21:52 +0200
From: Kostiantyn Rybnikov <k...@k-bx.com>
To: The Haskell-Beginners Mailing List - Discussion of primarily
        beginner-level topics related to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] How to show a predicate
Message-ID:
        <CAAbahfQZbsP+b=zaom6obkhcsf85ejh6iabhvjpteugyute...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

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.drautzb...@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@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-0001.html>

------------------------------

Message: 2
Date: Tue, 29 Dec 2015 12:00:50 +0100
From: Alexander Berntsen <alexan...@plaimi.net>
To: beginners@haskell.org
Subject: Re: [Haskell-beginners] explaining effects
Message-ID: <568267e2.8050...@plaimi.net>
Content-Type: text/plain; charset=windows-1252

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Rein explains effects well enough. Now for side-effects: a side-effect
is what is allowed to happen in the absence of a weak equivalence
between call-by-name (including memoised versions) and call-by-value[0].

Let's play "spot the side-effect!"

- -- Haskell function for adding two numbers.
f x y = x + y

- -- function in a language that happens to be syntactically like Haskell.
f x y = print "Hallo!" >> x + y

- -- program to evaluate the function.
- -- it just happens to be equal in Haskell and the Haskell-like language.
main = let a = f 4 2 in print a >> print a

evaluation-strategy     | call-by-need | call-by-value
- -------------------------------------------------------------
x + y                   | 6\n6         | 6\n6
print "Hallo" >> x + y  | Hallo!\n6\n6 | Hallo!\n6\nHallo!\n6

See how the latter function differs in call-by-need and call-by-value?
This is because it has a *side-effect* of printing stuff. This is not
allowed in Haskell. And in fact, the latter function is impossible in
Haskell.

As Rein was getting at by abstraction leaks -- side-effects have an
observable interaction with the outside world.

[0]  <https://www.cs.indiana.edu/~sabry/papers/purelyFunctional.ps>
- -- 
Alexander
alexan...@plaimi.net
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCgAGBQJWgmfhAAoJENQqWdRUGk8BZfkQAOft2e7RmRheu0ZGAXXj3P4m
4zPnJ5SQ//+TTM2rzH1b6ifoidGgEhKiyDr2IajXbj0wIbPLXqORByXUFx6E6I1q
rz9rslEb2XGwxTOm/Wi90IGO6niEPO1+/WCFCLE2G+Fh2M3uo381djlQfaS1MVla
1UtzElnX2bnpLfjeSjMFFB2joEuCCl8Gz+QXVGIX1H3BE+xSyM+vllDtkwob/6Bn
OyPckgGyiQlt5RpPoBsdEBU5qzrT5yJWaRWeiRIg293XrOPls3kM0GvhvaAFXmWr
1A/L391BQtw65xeGTlPArCi+xemwVsgwK2hdQWPmTrpJATveV0vN1OhQMkiI5b+Q
5SfKo0MKKWezRu7avIfaJ0IUB5Pl/FM+IhMFoHWM4oE5ixh7Vr91nslhOMjvAWgR
GzKyMuY63CLoy/1He5nNoCJ2Pjwdf65lUOD/sNJhjLbd2qw220UFE4L2SOLXLX5U
uBY1GF3C+biH2ai7utKU9RBXyV7p5dVcV4vft+Eb118QJmp3fFP26HS6IwuD3V8q
JNWAo7ZTK5vpujUHtee2J1ltHrleSlVaaJE0ONDzKDzi7QrwUAUbae3/Wnzy5zBF
ZXSPqABh8MNjkItax5zQwHyvgcJTRNtt7xj41+d7WKscgy5XvDQC3/RSQPXYZ9Ib
upR6CDDSP2bns7KfRDU0
=AGvd
-----END PGP SIGNATURE-----


------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 90, Issue 46
*****************************************

Reply via email to