diff options
author | Ćukasz Hanuszczak <lukasz.hanuszczak@gmail.com> | 2015-07-29 18:43:39 +0200 |
---|---|---|
committer | Mateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk> | 2015-08-21 18:22:33 +0100 |
commit | 730d8b0e76c5e637f2cdd7d980865f6208729366 (patch) | |
tree | fbe2d07c5772bef3133d7d8b1f12eb8063fada89 /haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs | |
parent | 00571a39acaa5aaa292b5a4bd5c17f122951f7ae (diff) |
Create helper method for specializing type signatures.
Diffstat (limited to 'haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs')
-rw-r--r-- | haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs index 109788fd..2295605b 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml/Specialize.hs @@ -5,11 +5,7 @@ module Haddock.Backends.Xhtml.Specialize - ( specialize, specialize' - , specializeTyVarBndrs - , specializePseudoFamilyDecl - , sugar, rename - , freeVariables + ( specializePseudoFamilyDecl, specializeSig ) where @@ -80,6 +76,18 @@ specializePseudoFamilyDecl bndrs typs decl = specializeTyVars = specializeTyVarBndrs bndrs typs +specializeSig :: (Eq name, Typeable name, DataId name, SetName name) + => LHsTyVarBndrs name -> [HsType name] + -> Sig name + -> Sig name +specializeSig bndrs typs (TypeSig lnames (L loc typ) prn) = + TypeSig lnames (L loc typ') prn + where + typ' = rename fv . sugar $ specializeTyVarBndrs bndrs typs typ + fv = foldr Set.union Set.empty . map freeVariables $ typs +specializeSig _ _ sig = sig + + -- | Make given type use tuple and list literals where appropriate. -- -- After applying 'specialize' function some terms may not use idiomatic list |