th-reify-compat (empty) → 0.0.1.0
raw patch · 6 files changed
+167/−0 lines, 6 filesdep +basedep +template-haskellsetup-changed
Dependencies added: base, template-haskell
Files
- LICENSE +30/−0
- Setup.hs +2/−0
- src/Language/Haskell/TH/Compat/Reify.hs +29/−0
- src/Language/Haskell/TH/Compat/Reify/Current.hs +23/−0
- src/Language/Haskell/TH/Compat/Reify/V210.hs +34/−0
- th-reify-compat.cabal +49/−0
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Language/Haskell/TH/Compat/Reify.hs view
@@ -0,0 +1,29 @@+{-# LANGUAGE CPP #-}++-- |+-- Module : Language.Haskell.TH.Compat.Reify+-- Copyright : 2016 Kei Hibino+-- License : BSD3+--+-- Maintainer : ex8k.hibino@gmail.com+-- Stability : experimental+-- Portability : unknown+--+-- This module provides compatibility definitions of+-- destructuring result type of reify for before temaplate-haskell-2.11+module Language.Haskell.TH.Compat.Reify (+ -- * Interfaces to destruct reify result+ unClassOpI, unDataConI, unVarI,++ -- * Interface to get operator fixity+ reifyFixity,++ -- * Interface of type alias name+ ParentName,+ ) where++#if MIN_VERSION_template_haskell(2,11,0)+import Language.Haskell.TH.Compat.Reify.Current+#else+import Language.Haskell.TH.Compat.Reify.V210+#endif
+ src/Language/Haskell/TH/Compat/Reify/Current.hs view
@@ -0,0 +1,23 @@+module Language.Haskell.TH.Compat.Reify.Current (+ ParentName,+ unClassOpI, unDataConI, unVarI,+ reifyFixity,+ )where++import Language.Haskell.TH (Info (..), Name, Type, ParentName, Dec, reifyFixity)+++-- | Compatible interface to destruct 'ClassOpI'+unClassOpI :: Info -> Maybe (Name, Type, ParentName)+unClassOpI (ClassOpI n t p) = Just (n, t, p)+unClassOpI _ = Nothing++-- | Compatible interface to destruct 'DataConI'+unDataConI :: Info -> Maybe (Name, Type, ParentName)+unDataConI (DataConI n t p) = Just (n, t, p)+unDataConI _ = Nothing++-- | Compatible interface to destruct 'VarI'+unVarI :: Info -> Maybe (Name, Type, Maybe Dec)+unVarI (VarI n t md) = Just (n, t, md)+unVarI _ = Nothing
+ src/Language/Haskell/TH/Compat/Reify/V210.hs view
@@ -0,0 +1,34 @@+module Language.Haskell.TH.Compat.Reify.V210 (+ ParentName,+ unClassOpI, unDataConI, unVarI,+ reifyFixity,+ )where++import Language.Haskell.TH (Info (..), Name, Type, Dec, Fixity)++-- | ParentName type alias is not defined before template-haskell-2.8+type ParentName = Name++-- | Compatible interface to destruct 'ClassOpI'+unClassOpI :: Info -> Maybe (Name, Type, ParentName)+unClassOpI (ClassOpI n t p _) = Just (n, t, p)+unClassOpI _ = Nothing++-- | Compatible interface to destruct 'DataConI'+unDataConI :: Info -> Maybe (Name, Type, ParentName)+unDataConI (DataConI n t p _) = Just (n, t, p)+unDataConI _ = Nothing++-- | Compatible interface to destruct 'VarI'+unVarI :: Info -> Maybe (Name, Type, Maybe Dec)+unVarI (VarI n t md _) = Just (n, t, md)+unVarI _ = Nothing++-- | Compatible interface to get operator fixity before temaplate-haskell-2.11+reifyFixity :: Info -> Maybe Fixity+reifyFixity = d+ where+ d (ClassOpI _ _ _ f) = Just f+ d (DataConI _ _ _ f) = Just f+ d (VarI _ _ _ f) = Just f+ d _ = Nothing
+ th-reify-compat.cabal view
@@ -0,0 +1,49 @@++name: th-reify-compat+version: 0.0.1.0+synopsis: Compatibility for the result type of TH reify+description: This package contains compatible interfaces against+ the result type of TH reify function.+homepage: http://github.com/khibino/haskell-th-reify-compat/+license: BSD3+license-file: LICENSE+author: Kei Hibino+maintainer: ex8k.hibino@gmail.com+copyright: Copyright (c) 2016 Kei Hibino+category: Language+build-type: Simple+cabal-version: >=1.10+tested-with: GHC == 7.4.1, GHC == 7.4.2+ , GHC == 7.6.1, GHC == 7.6.2, GHC == 7.6.3+ , GHC == 7.8.1, GHC == 7.8.2, GHC == 7.8.3, GHC == 7.8.4+ , GHC == 8.0.1++flag template-haskell-210+ description: If true, use template-haskell 2.10 or older, otherwise use template-haskell 2.11 or newer.+ default: True++library+ exposed-modules: Language.Haskell.TH.Compat.Reify+ if flag(template-haskell-210)+ other-modules:+ Language.Haskell.TH.Compat.Reify.V210+ build-depends: template-haskell <2.11+ else+ other-modules:+ Language.Haskell.TH.Compat.Reify.Current+ build-depends: template-haskell >=2.11++ 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-reify-compat++source-repository head+ type: mercurial+ location: https://bitbucket.org/khibino/haskell-th-reify-compat