packages feed

th-bang-compat (empty) → 0.0.1.0

raw patch · 7 files changed

+228/−0 lines, 7 filesdep +basedep +template-haskellsetup-changed

Dependencies added: base, template-haskell

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for th-bang-compat++## 0.0.1.0++* first revision. compat type constructors and functions.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (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.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Language/Haskell/TH/Compat/Bang.hs view
@@ -0,0 +1,36 @@+{-# 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
+ src/Language/Haskell/TH/Compat/Bang/Current.hs view
@@ -0,0 +1,23 @@+module 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, )
+ src/Language/Haskell/TH/Compat/Bang/V210.hs view
@@ -0,0 +1,78 @@+module 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.cabal view
@@ -0,0 +1,54 @@++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