th-data-compat-0.1.3.1/0000755000000000000000000000000007346545000012646 5ustar0000000000000000th-data-compat-0.1.3.1/LICENSE0000644000000000000000000000275607346545000013665 0ustar0000000000000000Copyright (c) 2016, Kei Hibino All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Kei Hibino nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. th-data-compat-0.1.3.1/Setup.hs0000644000000000000000000000005607346545000014303 0ustar0000000000000000import Distribution.Simple main = defaultMain th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/0000755000000000000000000000000007346545000020301 5ustar0000000000000000th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data.hs0000644000000000000000000000242507346545000021511 0ustar0000000000000000{-# LANGUAGE CPP #-} -- | -- Module : Language.Haskell.TH.Compat.Data -- Copyright : 2016-2017 Kei Hibino -- License : BSD3 -- -- Maintainer : ex8k.hibino@gmail.com -- Stability : experimental -- Portability : unknown -- -- This module provides compatibility definitions of -- data-type declaration templates for before temaplate-haskell-2.11 module Language.Haskell.TH.Compat.Data ( -- * Interfaces to construct data declarations dataD', newtypeD', dataInstD', newtypeInstD', plainTVspecified, -- * Interfaces to destruct data declarations unDataD, unNewtypeD, unDataInstD, unNewtypeInstD, unInstanceD, unTyVarBndr, ) where #if MIN_VERSION_template_haskell(2,21,0) import Language.Haskell.TH.Compat.Data.Current #elif MIN_VERSION_template_haskell(2,17,0) import Language.Haskell.TH.Compat.Data.V220 #elif MIN_VERSION_template_haskell(2,15,0) import Language.Haskell.TH.Compat.Data.V216 #elif MIN_VERSION_template_haskell(2,12,0) import Language.Haskell.TH.Compat.Data.V214 #elif MIN_VERSION_template_haskell(2,11,0) import Language.Haskell.TH.Compat.Data.V211 #else import Language.Haskell.TH.Compat.Data.V210 #endif #if MIN_VERSION_template_haskell(2,17,0) import Language.Haskell.TH.Compat.TyVarBndr.Current #else import Language.Haskell.TH.Compat.TyVarBndr.V216 #endif th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data/0000755000000000000000000000000007346545000021152 5ustar0000000000000000th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data/Current.hs0000644000000000000000000000567607346545000023146 0ustar0000000000000000module Language.Haskell.TH.Compat.Data.Current ( dataD', unDataD, newtypeD', unNewtypeD, dataInstD', unDataInstD, newtypeInstD', unNewtypeInstD, unInstanceD, ) where import Language.Haskell.TH (CxtQ, ConQ, TypeQ, DecQ, Cxt, Con, Type, Name, TyVarBndr, BndrVis, Kind, Dec (DataD, NewtypeD, DataInstD, NewtypeInstD, InstanceD), DerivClauseQ, DerivClause (..), Pred, dataD, newtypeD, dataInstD, newtypeInstD, derivClause, conT) derivesFromNames :: [Name] -> [DerivClauseQ] derivesFromNames ns = [derivClause Nothing $ map conT ns] unDerivClause :: DerivClause -> [Pred] unDerivClause (DerivClause _ ps) = ps -- | Definition against 'dataD', -- compatible with before temaplate-haskell-2.11 dataD' :: CxtQ -> Name -> [TyVarBndr BndrVis] -> [ConQ] -> [Name] -> DecQ dataD' cxt n bs cs ds = dataD cxt n bs Nothing cs $ derivesFromNames ds -- | Compatible interface to destruct 'DataD' unDataD :: Dec -> Maybe (Cxt, Name, [TyVarBndr BndrVis], Maybe Kind, [Con], [Type]) unDataD (DataD cxt n bs mk cs ds) = Just (cxt, n, bs, mk, cs, ds >>= unDerivClause) unDataD _ = Nothing -- | Definition against 'newtypeD', -- compatible with before temaplate-haskell-2.11 newtypeD' :: CxtQ -> Name -> [TyVarBndr BndrVis] -> ConQ -> [Name] -> DecQ newtypeD' cxt n bs c ds = newtypeD cxt n bs Nothing c $ derivesFromNames ds -- | Compatible interface to destruct 'NewtypeD' unNewtypeD :: Dec -> Maybe (Cxt, Name, [TyVarBndr BndrVis], Maybe Kind, Con, [Type]) unNewtypeD (NewtypeD cxt n bs mk c ds) = Just (cxt, n, bs, mk, c, ds >>= unDerivClause) unNewtypeD _ = Nothing -- | Definition against 'dataInstD', -- compatible with before temaplate-haskell-2.11 dataInstD' :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ dataInstD' cxt n as cs ds = dataInstD cxt n as Nothing cs $ derivesFromNames ds -- | Compatible interface to destruct 'DataInstD' unDataInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr ()], Type, Maybe Kind, [Con], [Type]) unDataInstD (DataInstD cxt b ty mk cs ds) = Just (cxt, b, ty, mk, cs, ds >>= unDerivClause) unDataInstD _ = Nothing -- | Definition against 'newtypeInstD', -- compatible with before temaplate-haskell-2.11 newtypeInstD' :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ newtypeInstD' cxt n as c ds = newtypeInstD cxt n as Nothing c $ derivesFromNames ds -- | Compatible interface to destruct 'NewtypeInstD' unNewtypeInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr ()], Type, Maybe Kind, Con, [Type]) unNewtypeInstD (NewtypeInstD cxt b ty mk c ds) = Just (cxt, b, ty, mk, c, ds >>= unDerivClause) unNewtypeInstD _ = Nothing -- | Compatible interface to destruct 'InstanceD' -- No Overlap type is defined before template-haskell-2.11. unInstanceD :: Dec -> Maybe (Cxt, Type, [Dec]) unInstanceD (InstanceD _ cxt ty decs) = Just (cxt, ty, decs) unInstanceD _ = Nothing th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data/Util.hs0000644000000000000000000000031107346545000022416 0ustar0000000000000000module Language.Haskell.TH.Compat.Data.Util ( foldAppT_, ) where import Language.Haskell.TH import Data.List (foldl') foldAppT_ :: Name -> [Type] -> Type foldAppT_ n as = foldl' AppT (ConT n) as th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data/V210.hs0000644000000000000000000000507707346545000022147 0ustar0000000000000000-- The latest version of applying this module impl is template-haskell-2.10 module Language.Haskell.TH.Compat.Data.V210 ( dataD', unDataD, newtypeD', unNewtypeD, dataInstD', unDataInstD, newtypeInstD', unNewtypeInstD, unInstanceD, ) where import Language.Haskell.TH (CxtQ, ConQ, TypeQ, DecQ, Cxt, Con, Type (ConT), Name, TyVarBndr, Kind, Dec (DataD, NewtypeD, DataInstD, NewtypeInstD, InstanceD), dataD, newtypeD, dataInstD, newtypeInstD) import Language.Haskell.TH.Compat.Data.Util (foldAppT_) -- | Definition against 'dataD', -- compatible with before temaplate-haskell-2.11 dataD' :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ dataD' = dataD -- | Compatible interface to destruct 'DataD' unDataD :: Dec -> Maybe (Cxt, Name, [TyVarBndr], Maybe Kind, [Con], [Type]) unDataD (DataD cxt n bs cs ds) = Just (cxt, n, bs, Nothing, cs, map ConT ds) unDataD _ = Nothing -- | Definition against 'newtypeD', -- compatible with before temaplate-haskell-2.11 newtypeD' :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ newtypeD' = newtypeD -- | Compatible interface to destruct 'NewtypeD' unNewtypeD :: Dec -> Maybe (Cxt, Name, [TyVarBndr], Maybe Kind, Con, [Type]) unNewtypeD (NewtypeD cxt n bs c ds) = Just (cxt, n, bs, Nothing, c, map ConT ds) unNewtypeD _ = Nothing -- | Definition against 'dataInstD', -- compatible with before temaplate-haskell-2.11 dataInstD' :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ dataInstD' = dataInstD -- | Compatible interface to destruct 'DataInstD' unDataInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, [Con], [Type]) unDataInstD (DataInstD cxt n as cs ds) = Just (cxt, Nothing, foldAppT_ n as, Nothing, cs, map ConT ds) unDataInstD _ = Nothing -- | Definition against 'newtypeInstD', -- compatible with before temaplate-haskell-2.11 newtypeInstD' :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ newtypeInstD' = newtypeInstD -- | Compatible interface to destruct 'NewtypeInstD' unNewtypeInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, Con, [Type]) unNewtypeInstD (NewtypeInstD cxt n as c ds) = Just (cxt, Nothing, foldAppT_ n as, Nothing, c, map ConT ds) unNewtypeInstD _ = Nothing -- | Compatible interface to destruct 'InstanceD'. -- No Overlap type is defined before template-haskell-2.11. unInstanceD :: Dec -> Maybe (Cxt, Type, [Dec]) unInstanceD (InstanceD cxt ty decs) = Just (cxt, ty, decs) unInstanceD _ = Nothing th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data/V211.hs0000644000000000000000000000534507346545000022146 0ustar0000000000000000-- The latest version of applying this module impl is template-haskell-2.11 module Language.Haskell.TH.Compat.Data.V211 ( dataD', unDataD, newtypeD', unNewtypeD, dataInstD', unDataInstD, newtypeInstD', unNewtypeInstD, unInstanceD, ) where import Language.Haskell.TH (CxtQ, ConQ, TypeQ, DecQ, Cxt, Con, Type, Name, TyVarBndr, Kind, Dec (DataD, NewtypeD, DataInstD, NewtypeInstD, InstanceD), dataD, newtypeD, dataInstD, newtypeInstD, conT) import Language.Haskell.TH.Compat.Data.Util (foldAppT_) -- | Definition against 'dataD', -- compatible with before temaplate-haskell-2.11 dataD' :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ dataD' cxt n bs cs ds = dataD cxt n bs Nothing cs $ mapM conT ds -- | Compatible interface to destruct 'DataD' unDataD :: Dec -> Maybe (Cxt, Name, [TyVarBndr], Maybe Kind, [Con], [Type]) unDataD (DataD cxt n bs mk cs ds) = Just (cxt, n, bs, mk, cs, ds) unDataD _ = Nothing -- | Definition against 'newtypeD', -- compatible with before temaplate-haskell-2.11 newtypeD' :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ newtypeD' cxt n bs c ds = newtypeD cxt n bs Nothing c $ mapM conT ds -- | Compatible interface to destruct 'NewtypeD' unNewtypeD :: Dec -> Maybe (Cxt, Name, [TyVarBndr], Maybe Kind, Con, [Type]) unNewtypeD (NewtypeD cxt n bs mk c ds) = Just (cxt, n, bs, mk, c, ds) unNewtypeD _ = Nothing -- | Definition against 'dataInstD', -- compatible with before temaplate-haskell-2.11 dataInstD' :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ dataInstD' cxt n as cs ds = dataInstD cxt n as Nothing cs $ mapM conT ds -- | Compatible interface to destruct 'DataInstD' unDataInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, [Con], [Type]) unDataInstD (DataInstD cxt n as mk cs ds) = Just (cxt, Nothing, foldAppT_ n as, mk, cs, ds) unDataInstD _ = Nothing -- | Definition against 'newtypeInstD', -- compatible with before temaplate-haskell-2.11 newtypeInstD' :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ newtypeInstD' cxt n as c ds = newtypeInstD cxt n as Nothing c $ mapM conT ds -- | Compatible interface to destruct 'NewtypeInstD' unNewtypeInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, Con, [Type]) unNewtypeInstD (NewtypeInstD cxt n as mk c ds) = Just (cxt, Nothing, foldAppT_ n as, mk, c, ds) unNewtypeInstD _ = Nothing -- | Compatible interface to destruct 'InstanceD' -- No Overlap type is defined before template-haskell-2.11. unInstanceD :: Dec -> Maybe (Cxt, Type, [Dec]) unInstanceD (InstanceD _ cxt ty decs) = Just (cxt, ty, decs) unInstanceD _ = Nothing th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data/V214.hs0000644000000000000000000000606507346545000022151 0ustar0000000000000000-- The latest version of applying this module impl is template-haskell-2.14 module Language.Haskell.TH.Compat.Data.V214 ( dataD', unDataD, newtypeD', unNewtypeD, dataInstD', unDataInstD, newtypeInstD', unNewtypeInstD, unInstanceD, ) where import Language.Haskell.TH (CxtQ, ConQ, TypeQ, DecQ, Cxt, Con, Type, Name, TyVarBndr, Kind, Dec (DataD, NewtypeD, DataInstD, NewtypeInstD, InstanceD), DerivClauseQ, DerivClause (..), Pred, dataD, newtypeD, dataInstD, newtypeInstD, derivClause, conT) import Language.Haskell.TH.Compat.Data.Util (foldAppT_) derivesFromNames :: [Name] -> [DerivClauseQ] derivesFromNames ns = [derivClause Nothing $ map conT ns] unDerivClause :: DerivClause -> [Pred] unDerivClause (DerivClause _ ps) = ps -- | Definition against 'dataD', -- compatible with before temaplate-haskell-2.11 dataD' :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ dataD' cxt n bs cs ds = dataD cxt n bs Nothing cs $ derivesFromNames ds -- | Compatible interface to destruct 'DataD' unDataD :: Dec -> Maybe (Cxt, Name, [TyVarBndr], Maybe Kind, [Con], [Type]) unDataD (DataD cxt n bs mk cs ds) = Just (cxt, n, bs, mk, cs, ds >>= unDerivClause) unDataD _ = Nothing -- | Definition against 'newtypeD', -- compatible with before temaplate-haskell-2.11 newtypeD' :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ newtypeD' cxt n bs c ds = newtypeD cxt n bs Nothing c $ derivesFromNames ds -- | Compatible interface to destruct 'NewtypeD' unNewtypeD :: Dec -> Maybe (Cxt, Name, [TyVarBndr], Maybe Kind, Con, [Type]) unNewtypeD (NewtypeD cxt n bs mk c ds) = Just (cxt, n, bs, mk, c, ds >>= unDerivClause) unNewtypeD _ = Nothing -- | Definition against 'dataInstD', -- compatible with before temaplate-haskell-2.11 dataInstD' :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ dataInstD' cxt n as cs ds = dataInstD cxt n as Nothing cs $ derivesFromNames ds -- | Compatible interface to destruct 'DataInstD' unDataInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, [Con], [Type]) unDataInstD (DataInstD cxt n as mk cs ds) = Just (cxt, Nothing, foldAppT_ n as, mk, cs, ds >>= unDerivClause) unDataInstD _ = Nothing -- | Definition against 'newtypeInstD', -- compatible with before temaplate-haskell-2.11 newtypeInstD' :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ newtypeInstD' cxt n as c ds = newtypeInstD cxt n as Nothing c $ derivesFromNames ds -- | Compatible interface to destruct 'NewtypeInstD' unNewtypeInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, Con, [Type]) unNewtypeInstD (NewtypeInstD cxt n as mk c ds) = Just (cxt, Nothing, foldAppT_ n as, mk, c, ds >>= unDerivClause) unNewtypeInstD _ = Nothing -- | Compatible interface to destruct 'InstanceD' -- No Overlap type is defined before template-haskell-2.11. unInstanceD :: Dec -> Maybe (Cxt, Type, [Dec]) unInstanceD (InstanceD _ cxt ty decs) = Just (cxt, ty, decs) unInstanceD _ = Nothing th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data/V216.hs0000644000000000000000000000573007346545000022151 0ustar0000000000000000-- The latest version of applying this module impl is template-haskell-2.16 module Language.Haskell.TH.Compat.Data.V216 ( dataD', unDataD, newtypeD', unNewtypeD, dataInstD', unDataInstD, newtypeInstD', unNewtypeInstD, unInstanceD, ) where import Language.Haskell.TH (CxtQ, ConQ, TypeQ, DecQ, Cxt, Con, Type, Name, TyVarBndr, Kind, Dec (DataD, NewtypeD, DataInstD, NewtypeInstD, InstanceD), DerivClauseQ, DerivClause (..), Pred, dataD, newtypeD, dataInstD, newtypeInstD, derivClause, conT) derivesFromNames :: [Name] -> [DerivClauseQ] derivesFromNames ns = [derivClause Nothing $ map conT ns] unDerivClause :: DerivClause -> [Pred] unDerivClause (DerivClause _ ps) = ps -- | Definition against 'dataD', -- compatible with before temaplate-haskell-2.11 dataD' :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ dataD' cxt n bs cs ds = dataD cxt n bs Nothing cs $ derivesFromNames ds -- | Compatible interface to destruct 'DataD' unDataD :: Dec -> Maybe (Cxt, Name, [TyVarBndr], Maybe Kind, [Con], [Type]) unDataD (DataD cxt n bs mk cs ds) = Just (cxt, n, bs, mk, cs, ds >>= unDerivClause) unDataD _ = Nothing -- | Definition against 'newtypeD', -- compatible with before temaplate-haskell-2.11 newtypeD' :: CxtQ -> Name -> [TyVarBndr] -> ConQ -> [Name] -> DecQ newtypeD' cxt n bs c ds = newtypeD cxt n bs Nothing c $ derivesFromNames ds -- | Compatible interface to destruct 'NewtypeD' unNewtypeD :: Dec -> Maybe (Cxt, Name, [TyVarBndr], Maybe Kind, Con, [Type]) unNewtypeD (NewtypeD cxt n bs mk c ds) = Just (cxt, n, bs, mk, c, ds >>= unDerivClause) unNewtypeD _ = Nothing -- | Definition against 'dataInstD', -- compatible with before temaplate-haskell-2.11 dataInstD' :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ dataInstD' cxt n as cs ds = dataInstD cxt n as Nothing cs $ derivesFromNames ds -- | Compatible interface to destruct 'DataInstD' unDataInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, [Con], [Type]) unDataInstD (DataInstD cxt b ty mk cs ds) = Just (cxt, b, ty, mk, cs, ds >>= unDerivClause) unDataInstD _ = Nothing -- | Definition against 'newtypeInstD', -- compatible with before temaplate-haskell-2.11 newtypeInstD' :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ newtypeInstD' cxt n as c ds = newtypeInstD cxt n as Nothing c $ derivesFromNames ds -- | Compatible interface to destruct 'NewtypeInstD' unNewtypeInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr], Type, Maybe Kind, Con, [Type]) unNewtypeInstD (NewtypeInstD cxt b ty mk c ds) = Just (cxt, b, ty, mk, c, ds >>= unDerivClause) unNewtypeInstD _ = Nothing -- | Compatible interface to destruct 'InstanceD' -- No Overlap type is defined before template-haskell-2.11. unInstanceD :: Dec -> Maybe (Cxt, Type, [Dec]) unInstanceD (InstanceD _ cxt ty decs) = Just (cxt, ty, decs) unInstanceD _ = Nothing th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/Data/V220.hs0000644000000000000000000000575207346545000022150 0ustar0000000000000000-- The latest version of applying this module impl is template-haskell-2.20 module Language.Haskell.TH.Compat.Data.V220 ( dataD', unDataD, newtypeD', unNewtypeD, dataInstD', unDataInstD, newtypeInstD', unNewtypeInstD, unInstanceD, ) where import Language.Haskell.TH (CxtQ, ConQ, TypeQ, DecQ, Cxt, Con, Type, Name, TyVarBndr, Kind, Dec (DataD, NewtypeD, DataInstD, NewtypeInstD, InstanceD), DerivClauseQ, DerivClause (..), Pred, dataD, newtypeD, dataInstD, newtypeInstD, derivClause, conT) derivesFromNames :: [Name] -> [DerivClauseQ] derivesFromNames ns = [derivClause Nothing $ map conT ns] unDerivClause :: DerivClause -> [Pred] unDerivClause (DerivClause _ ps) = ps -- | Definition against 'dataD', -- compatible with before temaplate-haskell-2.11 dataD' :: CxtQ -> Name -> [TyVarBndr ()] -> [ConQ] -> [Name] -> DecQ dataD' cxt n bs cs ds = dataD cxt n bs Nothing cs $ derivesFromNames ds -- | Compatible interface to destruct 'DataD' unDataD :: Dec -> Maybe (Cxt, Name, [TyVarBndr ()], Maybe Kind, [Con], [Type]) unDataD (DataD cxt n bs mk cs ds) = Just (cxt, n, bs, mk, cs, ds >>= unDerivClause) unDataD _ = Nothing -- | Definition against 'newtypeD', -- compatible with before temaplate-haskell-2.11 newtypeD' :: CxtQ -> Name -> [TyVarBndr ()] -> ConQ -> [Name] -> DecQ newtypeD' cxt n bs c ds = newtypeD cxt n bs Nothing c $ derivesFromNames ds -- | Compatible interface to destruct 'NewtypeD' unNewtypeD :: Dec -> Maybe (Cxt, Name, [TyVarBndr ()], Maybe Kind, Con, [Type]) unNewtypeD (NewtypeD cxt n bs mk c ds) = Just (cxt, n, bs, mk, c, ds >>= unDerivClause) unNewtypeD _ = Nothing -- | Definition against 'dataInstD', -- compatible with before temaplate-haskell-2.11 dataInstD' :: CxtQ -> Name -> [TypeQ] -> [ConQ] -> [Name] -> DecQ dataInstD' cxt n as cs ds = dataInstD cxt n as Nothing cs $ derivesFromNames ds -- | Compatible interface to destruct 'DataInstD' unDataInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr ()], Type, Maybe Kind, [Con], [Type]) unDataInstD (DataInstD cxt b ty mk cs ds) = Just (cxt, b, ty, mk, cs, ds >>= unDerivClause) unDataInstD _ = Nothing -- | Definition against 'newtypeInstD', -- compatible with before temaplate-haskell-2.11 newtypeInstD' :: CxtQ -> Name -> [TypeQ] -> ConQ -> [Name] -> DecQ newtypeInstD' cxt n as c ds = newtypeInstD cxt n as Nothing c $ derivesFromNames ds -- | Compatible interface to destruct 'NewtypeInstD' unNewtypeInstD :: Dec -> Maybe (Cxt, Maybe [TyVarBndr ()], Type, Maybe Kind, Con, [Type]) unNewtypeInstD (NewtypeInstD cxt b ty mk c ds) = Just (cxt, b, ty, mk, c, ds >>= unDerivClause) unNewtypeInstD _ = Nothing -- | Compatible interface to destruct 'InstanceD' -- No Overlap type is defined before template-haskell-2.11. unInstanceD :: Dec -> Maybe (Cxt, Type, [Dec]) unInstanceD (InstanceD _ cxt ty decs) = Just (cxt, ty, decs) unInstanceD _ = Nothing th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/TyVarBndr/0000755000000000000000000000000007346545000022154 5ustar0000000000000000th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/TyVarBndr/Current.hs0000644000000000000000000000062607346545000024136 0ustar0000000000000000module Language.Haskell.TH.Compat.TyVarBndr.Current ( plainTVspecified, unTyVarBndr, ) where import Language.Haskell.TH (Name, TyVarBndr (..), Specificity (SpecifiedSpec)) plainTVspecified :: Name -> TyVarBndr Specificity plainTVspecified n = PlainTV n SpecifiedSpec unTyVarBndr :: TyVarBndr a -> (Name, Maybe a) unTyVarBndr (PlainTV n f) = (n, Just f) unTyVarBndr (KindedTV n f _k) = (n, Just f) th-data-compat-0.1.3.1/src/Language/Haskell/TH/Compat/TyVarBndr/V216.hs0000644000000000000000000000064007346545000023146 0ustar0000000000000000-- The latest version of applying this module impl is template-haskell-2.16 module Language.Haskell.TH.Compat.TyVarBndr.V216 ( plainTVspecified, unTyVarBndr, ) where import Language.Haskell.TH (Name, TyVarBndr (..)) plainTVspecified :: Name -> TyVarBndr plainTVspecified = PlainTV unTyVarBndr :: TyVarBndr -> (Name, Maybe a) unTyVarBndr (PlainTV n) = (n, Nothing) unTyVarBndr (KindedTV n _k) = (n, Nothing) th-data-compat-0.1.3.1/th-data-compat.cabal0000644000000000000000000000614307346545000016441 0ustar0000000000000000cabal-version: >=1.10 name: th-data-compat version: 0.1.3.1 synopsis: Compatibility for data definition template of TH description: This package contains wrapped name definitions of data definition template license: BSD3 license-file: LICENSE author: Kei Hibino maintainer: ex8k.hibino@gmail.com copyright: Copyright (c) 2016-2023 Kei Hibino category: Language build-type: Simple tested-with: GHC == 9.8.1 , GHC == 9.6.2, GHC == 9.6.3 , GHC == 9.4.4, GHC == 9.4.6 , GHC == 9.2.1, GHC == 9.2.2, GHC == 9.2.5, GHC == 9.2.8 , GHC == 9.0.1, GHC == 9.0.2 , GHC == 8.10.1, GHC == 8.10.2, GHC == 8.10.3, GHC == 8.10.4, GHC == 8.10.5, GHC == 8.10.6, GHC == 8.10.7 , GHC == 8.8.1, GHC == 8.8.2, GHC == 8.8.3 , GHC == 8.6.1, GHC == 8.6.2, GHC == 8.6.3, GHC == 8.6.4, GHC == 8.6.5 , GHC == 8.4.1, GHC == 8.4.2, GHC == 8.4.3, GHC == 8.4.4 , GHC == 8.2.1, GHC == 8.2.2 , GHC == 8.0.1, GHC == 8.0.2 , GHC == 7.10.1, GHC == 7.10.2, GHC == 7.10.3 , GHC == 7.8.1, GHC == 7.8.2, GHC == 7.8.3, GHC == 7.8.4 , GHC == 7.6.1, GHC == 7.6.2, GHC == 7.6.3 , GHC == 7.4.1, GHC == 7.4.2 library exposed-modules: Language.Haskell.TH.Compat.Data other-modules: Language.Haskell.TH.Compat.Data.Util if impl(ghc >= 9.8) { other-modules: Language.Haskell.TH.Compat.Data.Current build-depends: template-haskell } else { if impl(ghc >= 9.0) { other-modules: Language.Haskell.TH.Compat.Data.V220 build-depends: template-haskell } else { if impl(ghc >= 8.8) { other-modules: Language.Haskell.TH.Compat.Data.V216 build-depends: template-haskell <2.17 } else { if impl(ghc >= 8.2) { other-modules: Language.Haskell.TH.Compat.Data.V214 build-depends: template-haskell <2.15 } else { if impl(ghc >= 8.0) { other-modules: Language.Haskell.TH.Compat.Data.V211 build-depends: template-haskell ==2.11.* } else { other-modules: Language.Haskell.TH.Compat.Data.V210 build-depends: template-haskell >=2.4 && <2.11 }}}}} if impl(ghc >= 9.0) other-modules: Language.Haskell.TH.Compat.TyVarBndr.Current else other-modules: Language.Haskell.TH.Compat.TyVarBndr.V216 build-depends: base <5 other-extensions: CPP hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall source-repository head type: git location: https://github.com/khibino/haskell-th-data-compat source-repository head type: mercurial location: https://bitbucket.org/khibino/haskell-th-data-compat