diff --git a/Data/Record/TH.hs b/Data/Record/TH.hs
new file mode 100644
--- /dev/null
+++ b/Data/Record/TH.hs
@@ -0,0 +1,106 @@
+{-# LANGUAGE TemplateHaskell, TypeOperators, FlexibleInstances, FlexibleContexts, TypeFamilies #-}
+module Data.Record.TH (JSONSpec(..), fields, Field, Rec, TypeOf) where
+import Data.Record
+import Language.Haskell.TH hiding (Name)
+import Data.Aeson
+import Data.Aeson.Types
+import Data.Default
+import Data.Text (Text)
+import qualified Data.Text as T
+import Control.Monad
+import Data.Kind
+import Data.TypeFun
+import qualified Data.HashMap.Strict as H
+
+-- | Specify what level of JSON generation you want
+data JSONSpec = ALL | TO | FROM | NONE deriving (Show, Eq)
+
+class ToJSONField a where
+	toJSONField :: a -> (Text,Value)
+
+class FromJSONField a where
+	fromJSONField :: Object -> Parser a
+
+-- | The data carried by a particular field name
+type family TypeOf c
+
+-- | A field representing its TypeOf
+type Field a = (a ::: TypeOf a)
+
+-- | A record of kind *
+type Rec a = a (Id KindStar)
+
+-- | Generate field declarations for the given strings. For example:
+-- @
+--  $(fields ["A", "B"])
+-- @
+-- generates the code
+-- @
+-- data A = A
+-- instance Name A where name = A
+-- @
+fields :: [(String, TypeQ, JSONSpec)] -> Q [Dec]
+fields ss = liftM concat $ forM ss $ \(s,t,a)-> do
+	let n = mkName s
+	t' <- t
+	y <- newName "y"
+	f <- newName "f"
+	ty <- appT (appT (appT [t|(:::)|] (conT n)) t) [t| Id KindStar|]
+	let op = case t' of
+		(AppT (ConT a) _) -> if a == ''Maybe then '(.:?) else '(.:)
+		_ -> '(.:)
+	let main = [
+		DataD [] n [] [NormalC n []] [''Show],
+		InstanceD [] (AppT (ConT ''Name) (ConT n)) [
+			FunD 'name [Clause [] (NormalB (ConE n)) []]],
+		TySynInstD ''TypeOf [ConT n] t']
+	let to = 
+		InstanceD [] (AppT (ConT ''ToJSONField) ty) [
+			FunD 'toJSONField [
+				Clause [ ConP '(:=) [WildP, VarP y]]
+				(NormalB $ TupE [LitE $ StringL s, AppE (VarE 'toJSON) (VarE y)]) [] ]]
+	let from = 
+		InstanceD [] (AppT (ConT ''FromJSONField) ty) [
+			FunD 'fromJSONField [
+				Clause [VarP y] (
+					NormalB $  DoE [
+						BindS (VarP f) (AppE (AppE (VarE op) (VarE y)) (LitE $ StringL s)),
+						NoBindS $ AppE (VarE 'return) (AppE (AppE (ConE '(:=)) (ConE n)) (VarE f)) ]) []]]
+	case a of
+		NONE -> return main
+		FROM -> return $ main ++ [from]
+		TO -> return $ main ++ [to]
+		ALL -> return $ main ++ [to, from]
+
+instance ToJSON (X (Id KindStar)) where toJSON X = Object H.empty
+instance (ToJSON (a (Id KindStar)), ToJSONField (b (Id KindStar))) => ToJSON ((a :& b) (Id KindStar)) where
+	toJSON (a :& b) =
+		case toJSON a of
+			Object o ->
+				let (k,v) = toJSONField b
+				in if v == Null then Object o else Object (H.insert k v o)
+			_ -> error "Expecting an object in toJSON method"
+
+instance FromJSON (X (Id KindStar)) where parseJSON _ = return X
+instance (FromJSON (a (Id KindStar)), FromJSONField (b (Id KindStar))) => FromJSON ((a :& b) (Id KindStar)) where
+	parseJSON a@(Object o) = do
+		rest <- parseJSON a
+		it <- fromJSONField o
+		return $ rest :& it
+	parseJSON _ = mzero
+
+instance Default (X style) where def = X
+instance (Default (a style), Default (App style f), Name n) => Default ((a :& (n ::: f)) style) where
+	def = def :& name := def
+
+{-
+instance ToJSON x => ToJSONField ((A ::: x) (Id KindStar)) where
+	toJSONField (A := x) = ("A", toJSON x)
+-}
+
+{-
+instance FromJSON x => FromJSONField ((A ::: Maybe x) (Id KindStar)) where
+	fromJSONField o = do
+		n <- o .:? "A"
+		return $ A := n
+-}
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,7 @@
+Copyright (c) 2012 Sam Anklesaria
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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/records-th.cabal b/records-th.cabal
new file mode 100644
--- /dev/null
+++ b/records-th.cabal
@@ -0,0 +1,26 @@
+-- Initial records-th.cabal generated by cabal init.  For further 
+-- documentation, see http://haskell.org/cabal/users-guide/
+
+name:                records-th
+version:             0.1.0.0
+synopsis:            Template Haskell declarations for the records package
+description:         Records-TH generates a variety of declarations for use with the records package,
+                     including datatypes, Name, FromJSON, ToJSON and Default instances, and a default field type.
+homepage:            github.com/lassoinc/records-th
+license:             MIT
+license-file:        LICENSE
+author:              Sam Anklesaria
+maintainer:          amsay@amsay.net
+-- copyright:           
+category:            Data
+build-type:          Simple
+cabal-version:       >=1.8
+source-repository head
+  type:     git
+  location: git://github.com/bogiebro/records-th.git
+
+
+library
+  exposed-modules:     Data.Record.TH
+  -- other-modules:       
+  build-depends:       base ==4.5.*, records ==0.1.*, template-haskell ==2.7.*, aeson ==0.6.*, text ==0.11.*, kinds ==0.0.*, type-functions ==0.2.*, unordered-containers ==0.2.*, data-default == 0.4.*
