diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2016 Simon Hengel <sol@typeful.net>
+
+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.lhs b/Setup.lhs
new file mode 100644
--- /dev/null
+++ b/Setup.lhs
@@ -0,0 +1,3 @@
+#!/usr/bin/env runhaskell
+> import Distribution.Simple
+> main = defaultMain
diff --git a/includes/with-location.h b/includes/with-location.h
new file mode 100644
--- /dev/null
+++ b/includes/with-location.h
@@ -0,0 +1,16 @@
+#if MIN_VERSION_base(4,8,1)
+#define HAS_SOURCE_LOCATIONS
+{-# LANGUAGE ImplicitParams #-}
+#endif
+
+#ifdef HAS_SOURCE_LOCATIONS
+
+#define with_location (?loc :: CallStack) =>
+#define with_location_imports import GHC.Stack (CallStack)
+
+#else
+
+#define with_location
+#define with_location_imports
+
+#endif
diff --git a/src/Data/WithLocation.hs b/src/Data/WithLocation.hs
new file mode 100644
--- /dev/null
+++ b/src/Data/WithLocation.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE CPP #-}
+#include "with-location.h"
+module Data.WithLocation where
+
+#ifdef HAS_SOURCE_LOCATIONS
+#if !(MIN_VERSION_base(4,9,0))
+import           GHC.SrcLoc
+#endif
+import           GHC.Stack
+#endif
+
+data Location = Location {
+  locationPackage :: String
+, locationModule :: String
+, locationFile :: FilePath
+, locationLine :: Int
+, locationColumn :: Int
+} deriving (Eq, Ord, Show)
+
+location :: with_location Maybe Location
+#ifdef HAS_SOURCE_LOCATIONS
+location = case reverse (getCallStack ?loc) of
+  (_, loc) : _ -> Just $ Location (srcLocPackage loc) (srcLocModule loc) (srcLocFile loc) (srcLocStartLine loc) (srcLocStartCol loc)
+  [] -> Nothing
+#else
+location = Nothing
+#endif
diff --git a/with-location.cabal b/with-location.cabal
new file mode 100644
--- /dev/null
+++ b/with-location.cabal
@@ -0,0 +1,33 @@
+-- This file has been generated from package.yaml by hpack version 0.10.0.
+--
+-- see: https://github.com/sol/hpack
+
+name:                   with-location
+version:                0.0.0
+synopsis:               Use ImplicitParams-based source locations in a backward compatible way
+category:               Data
+homepage:               https://github.com/sol/with-location#readme
+bug-reports:            https://github.com/sol/with-location/issues
+maintainer:             Simon Hengel <sol@typeful.net>
+license:                MIT
+license-file:           LICENSE
+cabal-version:          >= 1.10
+build-type:             Simple
+
+source-repository head
+  type: git
+  location: https://github.com/sol/with-location
+
+library
+  hs-source-dirs:
+      src
+  ghc-options: -Wall
+  include-dirs:
+      includes
+  install-includes:
+      with-location.h
+  build-depends:
+      base == 4.*
+  exposed-modules:
+      Data.WithLocation
+  default-language: Haskell2010
