1 -----------------------------------------------------------------------------
3 -- Module : Data.Generics.Shortcuts
4 -- Copyright : (c) The University of Glasgow, CWI 2001--2003
5 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : experimental
9 -- Portability : non-portable
11 -- "Scrap your boilerplate" --- Generic programming in Haskell
12 -- See <http://www.cs.vu.nl/boilerplate/>.
14 -----------------------------------------------------------------------------
16 module Data.Generics.Shortcuts (
18 -- * Cut-off traversal
23 -----------------------------------------------------------------------------
26 import Data.Generics.Basics
27 import Data.Generics.Aliases
28 import Data.Generics.Types
31 -----------------------------------------------------------------------------
34 -- Run-time cut-off for top-down traversal with one specific type case.
35 -- This is only for illustrative purposes.
36 -- The naive approach here is prohibitively inefficient.
38 everywhere1RT' :: (Data a, Data b) => (a -> a) -> b -> b
40 if not $ typeReachableFrom (argType f) (typeValOf t)
42 else gmapT (everywhere1RT' f) (mkT f t)