[Haskell-beginners] Pattern matching over functions
Ertugrul Söylemez
es at ertes.de
Mon Dec 12 16:58:33 CET 2011
Graham Gill <math.simplex at gmail.com> wrote:
> > > But then we would lose referential transparency.
> >
> > As I understand, this would be against lazy evaluation since it
> > would request to evaluate expressions in lambda, but I don't see how
> > this relates to referential transparency. Can you elaborate this a
> > little bit?
>
> I second the question.
Referential transparency /requires/ that
id x = x
even if 'x' is a function, and this can, as Brent already noted,
arbitrarily complicated. If pattern matching could tell f from id f,
then referential transparency is violated. The only possible way to
tell f from id f is very unsafe and needs IO, hence not usable in
pattern matching.
Greets,
Ertugrul
--
nightmare = unsafePerformIO (getWrongWife >>= sex)
http://ertes.de/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111212/543b59a0/attachment-0001.pgp>
More information about the Beginners
mailing list