diff options
author | Ćukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-07-10 12:24:12 +0200 |
---|---|---|
committer | Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> | 2015-08-21 18:22:29 +0100 |
commit | dc25b7099a0d54c03bdf51dfb9a4e286942d9c31 (patch) | |
tree | 435ebaca235acaceaa50b78255e1320cffd2b8ca /haddock-api/src/Haddock/Syb.hs | |
parent | f7d377ee238d3b44240a4537986a7561e822f79f (diff) |
Implement generic transformation constructor.
Diffstat (limited to 'haddock-api/src/Haddock/Syb.hs')
-rw-r--r-- | haddock-api/src/Haddock/Syb.hs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/haddock-api/src/Haddock/Syb.hs b/haddock-api/src/Haddock/Syb.hs index 3cec724e..2016b74c 100644 --- a/haddock-api/src/Haddock/Syb.hs +++ b/haddock-api/src/Haddock/Syb.hs @@ -3,6 +3,7 @@ module Haddock.Syb ( everything, everywhere + , mkT , combine ) where @@ -25,6 +26,14 @@ everything k f x = foldl k (f x) (gmapQ (everything k f) x) everywhere :: (forall a. Data a => a -> a) -> (forall a. Data a => a -> a) everywhere f = f . gmapT (everywhere f) +-- | Create generic transformation. +-- +-- Another function stolen from SYB package. +mkT :: (Typeable a, Typeable b) => (b -> b) -> (a -> a) +mkT f = case cast f of + Just f' -> f' + Nothing -> id + -- | 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) |