From e4740dd872d1110247557eb7b20124c22e427789 Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Fri, 10 Jul 2015 16:23:15 +0200 Subject: Create simple utility module for type specialization. --- .../src/Haddock/Backends/Xhtml/Specialize.hs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs (limited to 'haddock-api/src/Haddock/Backends/Xhtml') diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs new file mode 100644 index 00000000..a0d64c0f --- /dev/null +++ b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE FlexibleContexts #-} + + +module Haddock.Backends.Xhtml.Specialize (specialize) where + + +import Haddock.Syb + +import GHC + +import Data.Data + + +specialize :: (Eq name, Data (HsType name)) + => name -> HsType name -> HsType name -> HsType name +specialize name details = everywhere (mkT $ specialize' name details) + +specialize' :: Eq name => name -> HsType name -> HsType name -> HsType name +specialize' name details (HsTyVar name') | name == name' = details +specialize' _ _ typ = typ + \ No newline at end of file -- cgit v1.2.3