diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 2017, 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.
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/src/Language/Haskell/TH/Compat/Constraint.hs b/src/Language/Haskell/TH/Compat/Constraint.hs
new file mode 100644
--- /dev/null
+++ b/src/Language/Haskell/TH/Compat/Constraint.hs
@@ -0,0 +1,22 @@
+{-# LANGUAGE CPP #-}
+
+-- |
+-- Module      : Language.Haskell.TH.Compat.Constraint
+-- Copyright   : 2017 Kei Hibino
+-- License     : BSD3
+--
+-- Maintainer  : ex8k.hibino@gmail.com
+-- Stability   : experimental
+-- Portability : unknown
+--
+-- This module provides compatibility definitions of
+-- constraint context template for before temaplate-haskell-2.9
+module Language.Haskell.TH.Compat.Constraint (
+  classP,
+  ) where
+
+#if MIN_VERSION_template_haskell(2,10,0)
+import Language.Haskell.TH.Compat.Constraint.Current
+#else
+import Language.Haskell.TH.Compat.Constraint.V209
+#endif
diff --git a/src/Language/Haskell/TH/Compat/Constraint/Current.hs b/src/Language/Haskell/TH/Compat/Constraint/Current.hs
new file mode 100644
--- /dev/null
+++ b/src/Language/Haskell/TH/Compat/Constraint/Current.hs
@@ -0,0 +1,10 @@
+module Language.Haskell.TH.Compat.Constraint.Current (
+  classP,
+  ) where
+
+import Language.Haskell.TH (Q, Name, Type, Pred, conT, appT)
+
+-- | type-class predicate context.
+--   definition to keep backward comatiblity.
+classP :: Name -> [Q Type] -> Q Pred
+classP cla tys = foldl appT (conT cla) tys
diff --git a/src/Language/Haskell/TH/Compat/Constraint/V209.hs b/src/Language/Haskell/TH/Compat/Constraint/V209.hs
new file mode 100644
--- /dev/null
+++ b/src/Language/Haskell/TH/Compat/Constraint/V209.hs
@@ -0,0 +1,5 @@
+module Language.Haskell.TH.Compat.Constraint.V209 (
+  classP,
+  ) where
+
+import Language.Haskell.TH (classP)
diff --git a/th-constraint-compat.cabal b/th-constraint-compat.cabal
new file mode 100644
--- /dev/null
+++ b/th-constraint-compat.cabal
@@ -0,0 +1,53 @@
+
+name:                th-constraint-compat
+version:             0.0.1.0
+synopsis:            Compatibility for type constraint template
+description:         This package provides compatibe interfaces
+                     for type constraint template
+license:             BSD3
+license-file:        LICENSE
+author:              Kei Hibino
+maintainer:          ex8k.hibino@gmail.com
+copyright:           Copyright (c) 2017 Kei Hibino
+category:            Language
+build-type:          Simple
+cabal-version:       >=1.10
+tested-with:           GHC == 8.2.1
+                     , 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-209
+       description: If true, use template-haskell 2.9 or older, otherwise use template-haskell 2.10 or newer.
+       default:     False
+
+library
+  exposed-modules:
+                       Language.Haskell.TH.Compat.Constraint
+
+  if flag(template-haskell-209)
+    other-modules:
+                       Language.Haskell.TH.Compat.Constraint.V209
+    build-depends:       template-haskell >=2.7 && <2.10
+  else
+    other-modules:
+                       Language.Haskell.TH.Compat.Constraint.Current
+    build-depends:       template-haskell >=2.10
+
+  build-depends:         base <5
+                       , containers
+
+  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-constraint-compat
+
+source-repository head
+  type:       mercurial
+  location:   https://bitbucket.org/khibino/haskell-th-constraint-compat
