Created
March 4, 2014 21:16
-
-
Save pedrofurla/9355837 to your computer and use it in GitHub Desktop.
A very humble usage of SYB (so far)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| isIdent :: String -> Ident -> Bool | |
| isIdent s (Ident id') = id' == s | |
| isIdentG :: forall a. Typeable a => String -> a -> Bool | |
| isIdentG s = False `mkQ` (isIdent s) | |
| {-| One level search of `Ident`s -} | |
| withId1 :: forall a. Data a => String -> a -> Bool | |
| withId1 s = or . (gmapQ (isIdentG s)) -- This saves me from matching against 7 different constructors | |
| {-| Search a given `Ident` on all levels -} | |
| withId :: forall a. Data a => String -> a -> Bool | |
| withId s = everything (||) (isIdentG s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment