th-bang-compat-0.0.1.0/0000755000000000000000000000000013477156645012657 5ustar0000000000000000th-bang-compat-0.0.1.0/Setup.hs0000644000000000000000000000005613477156645014314 0ustar0000000000000000import Distribution.Simple main = defaultMain th-bang-compat-0.0.1.0/th-bang-compat.cabal0000644000000000000000000000366113477156645016452 0ustar0000000000000000 name: th-bang-compat version: 0.0.1.0 synopsis: Compatibility for bang-type template description: This package provides compatible interfaces for bang-type template license: BSD3 license-file: LICENSE author: Kei Hibino maintainer: ex8k.hibino@gmail.com copyright: Copyright (c) 2019 Kei Hibino category: Language build-type: Simple extra-source-files: ChangeLog.md cabal-version: >=1.10 tested-with: 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 flag template-haskell-210 description: If true, use template-haskell 2.10 or older, otherwise use template-haskell 2.10 or newer. default: False library exposed-modules: Language.Haskell.TH.Compat.Bang if flag(template-haskell-210) other-modules: Language.Haskell.TH.Compat.Bang.V210 build-depends: template-haskell <2.11 else other-modules: Language.Haskell.TH.Compat.Bang.Current build-depends: template-haskell >=2.11 -- other-extensions: build-depends: base <5 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall source-repository head type: git location: https://github.com/khibino/haskell-th-bang-compat source-repository head type: mercurial location: https://bitbucket.org/khibino/haskell-th-bang-compat th-bang-compat-0.0.1.0/ChangeLog.md0000644000000000000000000000015513477156645015031 0ustar0000000000000000# Revision history for th-bang-compat ## 0.0.1.0 * first revision. compat type constructors and functions. th-bang-compat-0.0.1.0/LICENSE0000644000000000000000000000275613477156645013676 0ustar0000000000000000Copyright (c) 2019, 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-bang-compat-0.0.1.0/src/0000755000000000000000000000000013477156645013446 5ustar0000000000000000th-bang-compat-0.0.1.0/src/Language/0000755000000000000000000000000013477156645015171 5ustar0000000000000000th-bang-compat-0.0.1.0/src/Language/Haskell/0000755000000000000000000000000013477156645016554 5ustar0000000000000000th-bang-compat-0.0.1.0/src/Language/Haskell/TH/0000755000000000000000000000000013477156645017067 5ustar0000000000000000th-bang-compat-0.0.1.0/src/Language/Haskell/TH/Compat/0000755000000000000000000000000013477156645020312 5ustar0000000000000000th-bang-compat-0.0.1.0/src/Language/Haskell/TH/Compat/Bang.hs0000644000000000000000000000172613477156645021523 0ustar0000000000000000{-# LANGUAGE CPP #-} -- | -- Module : Language.Haskell.TH.Compat.Bang -- Copyright : 2019 Kei Hibino -- License : BSD3 -- -- Maintainer : ex8k.hibino@gmail.com -- Stability : experimental -- Portability : unknown -- -- This module provides compatibility definitions of -- bang-type template for before temaplate-haskell-2.10 module Language.Haskell.TH.Compat.Bang ( -- * Compat type constructors Bang, BangQ, BangType, BangTypeQ, VarBangType, VarBangTypeQ, SourceUnpackedness (NoSourceUnpackedness, SourceNoUnpack, SourceUnpack), SourceUnpackednessQ, SourceStrictness (NoSourceStrictness, SourceLazy, SourceStrict), SourceStrictnessQ, -- * Compat functions bang, bangType, varBangType, noSourceUnpackedness, sourceNoUnpack, sourceUnpack, noSourceStrictness, sourceLazy, sourceStrict, ) where #if MIN_VERSION_template_haskell(2,11,0) import Language.Haskell.TH.Compat.Bang.Current #else import Language.Haskell.TH.Compat.Bang.V210 #endif th-bang-compat-0.0.1.0/src/Language/Haskell/TH/Compat/Bang/0000755000000000000000000000000013477156645021161 5ustar0000000000000000th-bang-compat-0.0.1.0/src/Language/Haskell/TH/Compat/Bang/V210.hs0000644000000000000000000000431113477156645022144 0ustar0000000000000000module Language.Haskell.TH.Compat.Bang.V210 ( Bang, BangQ, BangType, BangTypeQ, VarBangType, VarBangTypeQ, bang, bangType, varBangType, SourceUnpackedness (..), SourceUnpackednessQ, SourceStrictness (..), SourceStrictnessQ, noSourceUnpackedness, sourceNoUnpack, sourceUnpack, noSourceStrictness, sourceLazy, sourceStrict, ) where import Language.Haskell.TH.Syntax (Strict, StrictType, VarStrictType) import Language.Haskell.TH.Lib (unpacked) import Language.Haskell.TH (Q, TypeQ, Name, notStrict, isStrict, strictType, varStrictType) type Bang = Strict type BangQ = Q Bang type BangType = StrictType type BangTypeQ = Q BangType type VarBangType = VarStrictType type VarBangTypeQ = Q VarBangType type SourceStrictnessQ = Q SourceStrictness type SourceUnpackednessQ = Q SourceUnpackedness bang :: SourceUnpackednessQ -> SourceStrictnessQ -> BangQ bang qu qs = do u <- qu s <- qs dispatch u s where dispatch :: SourceUnpackedness -> SourceStrictness -> BangQ dispatch NoSourceUnpackedness NoSourceStrictness = notStrict dispatch NoSourceUnpackedness SourceLazy = fail "SourceLazy is not supported in this version of template-haskell." dispatch NoSourceUnpackedness SourceStrict = isStrict dispatch SourceNoUnpack _ = fail "SourceNoUnpack is not supported in this version of template-haskell." dispatch SourceUnpack _ = unpacked bangType :: BangQ -> TypeQ -> BangTypeQ bangType = strictType varBangType :: Name -> BangTypeQ -> VarBangTypeQ varBangType = varStrictType ----- -- fake constructors for `bang` interface data SourceUnpackedness = NoSourceUnpackedness | SourceNoUnpack | SourceUnpack deriving (Show, Eq, Ord) noSourceUnpackedness, sourceNoUnpack, sourceUnpack :: SourceUnpackednessQ noSourceUnpackedness = return NoSourceUnpackedness sourceNoUnpack = return SourceNoUnpack sourceUnpack = return SourceUnpack data SourceStrictness = NoSourceStrictness | SourceLazy | SourceStrict deriving (Show, Eq, Ord) noSourceStrictness, sourceLazy, sourceStrict :: SourceStrictnessQ noSourceStrictness = return NoSourceStrictness sourceLazy = return SourceLazy sourceStrict = return SourceStrict th-bang-compat-0.0.1.0/src/Language/Haskell/TH/Compat/Bang/Current.hs0000644000000000000000000000135113477156645023137 0ustar0000000000000000module Language.Haskell.TH.Compat.Bang.Current ( Bang, BangQ, BangType, BangTypeQ, VarBangType, VarBangTypeQ, bang, bangType, varBangType, SourceUnpackedness (..), SourceUnpackednessQ, SourceStrictness (..), SourceStrictnessQ, noSourceUnpackedness, sourceNoUnpack, sourceUnpack, noSourceStrictness, sourceLazy, sourceStrict, ) where import Language.Haskell.TH.Syntax (Bang, BangType, VarBangType,) import Language.Haskell.TH.Lib (BangQ) import Language.Haskell.TH (bang, BangTypeQ, bangType, VarBangTypeQ, varBangType, SourceUnpackedness (..), SourceUnpackednessQ, SourceStrictness (..), SourceStrictnessQ, noSourceUnpackedness, sourceNoUnpack, sourceUnpack, noSourceStrictness, sourceLazy, sourceStrict, )