diff options
author | Ćukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-07-10 11:49:02 +0200 |
---|---|---|
committer | Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> | 2015-08-21 18:22:29 +0100 |
commit | f7d377ee238d3b44240a4537986a7561e822f79f (patch) | |
tree | 2d8df74844a9c29345991e06156845630db596be /haddock-api/src/Haddock | |
parent | e9d61b79faf40200d8f9806d83a05ece272cd7d3 (diff) |
Implement `everywhere` transformation in SYB module.
Diffstat (limited to 'haddock-api/src/Haddock')
-rw-r--r-- | haddock-api/src/Haddock/Syb.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/haddock-api/src/Haddock/Syb.hs b/haddock-api/src/Haddock/Syb.hs index dd7ffc1b..3cec724e 100644 --- a/haddock-api/src/Haddock/Syb.hs +++ b/haddock-api/src/Haddock/Syb.hs @@ -2,7 +2,7 @@ module Haddock.Syb - ( everything + ( everything, everywhere , combine ) where @@ -19,6 +19,12 @@ everything :: (r -> r -> r) -> (forall a. Data a => a -> r) -> (forall a. Data a => a -> r) everything k f x = foldl k (f x) (gmapQ (everything k f) x) +-- | Apply transformation on each level of a tree. +-- +-- Just like 'everything', this is stolen from SYB package. +everywhere :: (forall a. Data a => a -> a) -> (forall a. Data a => a -> a) +everywhere f = f . gmapT (everywhere f) + -- | Combine two queries into one using alternative combinator. combine :: Alternative f => (forall a. Data a => a -> f r) -> (forall a. Data a => a -> f r) |