Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. Haskell's Scrap Your Boilerplate (SYB) - applying
transformation only once instead of everywhere (Duc le anh)
----------------------------------------------------------------------
Message: 1
Date: Tue, 4 Jun 2013 00:31:31 -0700
From: Duc le anh <[email protected]>
Subject: [Haskell-beginners] Haskell's Scrap Your Boilerplate (SYB) -
applying transformation only once instead of everywhere
To: [email protected]
Message-ID:
<CADONhrujKGTh38fBg6QE8aHhX3h6cOuHVeiXFgX=kjynqo6...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
What's the best way to apply a transformation to a tree only once instead
of everywhere using SYB? For instance, in the following simplified
expression, there are several instances of Var "x", and I want to replace
the first instance with Var "y" only.
data Exp = Var String | Val Int | Plus Exp Exp |...
myExp = Val 5 `Plus` Var "x" `Plus` Val 5 `Plus` Var "x" ...
This can't be done using the everywhere combinator since it will try to
transform all instances of Var "x" toVar "y".
--
Duc A. Le
PS: I also asked this on stackoverflow but figured that I might get a
faster response here. Thank you!
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20130604/248d2198/attachment-0001.htm>
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 60, Issue 5
****************************************