diff --git a/includes/with-location.h b/includes/with-location.h
deleted file mode 100644
--- a/includes/with-location.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#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
--- a/src/Data/WithLocation.hs
+++ b/src/Data/WithLocation.hs
@@ -1,5 +1,11 @@
 {-# LANGUAGE CPP #-}
-#include "with-location.h"
+{-# LANGUAGE Rank2Types #-}
+
+#if MIN_VERSION_base(4,8,1)
+#define HAS_SOURCE_LOCATIONS
+{-# LANGUAGE ImplicitParams #-}
+#endif
+
 module Data.WithLocation where
 
 #ifdef HAS_SOURCE_LOCATIONS
@@ -9,6 +15,12 @@
 import           GHC.Stack
 #endif
 
+#ifdef HAS_SOURCE_LOCATIONS
+type WithLocation a = (?loc :: CallStack) => a
+#else
+type WithLocation a = a
+#endif
+
 data Location = Location {
   locationPackage :: String
 , locationModule :: String
@@ -17,7 +29,7 @@
 , locationColumn :: Int
 } deriving (Eq, Ord, Show)
 
-location :: with_location Maybe Location
+location :: WithLocation (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)
diff --git a/test/Data/WithLocationSpec.hs b/test/Data/WithLocationSpec.hs
new file mode 100644
--- /dev/null
+++ b/test/Data/WithLocationSpec.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE CPP #-}
+module Data.WithLocationSpec (spec) where
+
+import           Test.Hspec
+
+import           Data.WithLocation
+
+spec :: Spec
+spec = do
+  describe "location" $ do
+    it "returns a source location" $ do
+#if MIN_VERSION_base(4,8,1)
+      location `shouldBe` Just (Location "main" "Data.WithLocationSpec" __FILE__ __LINE__ 7)
+#else
+      location `shouldBe` Nothing
+#endif
diff --git a/test/Spec.hs b/test/Spec.hs
new file mode 100644
--- /dev/null
+++ b/test/Spec.hs
@@ -0,0 +1,1 @@
+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
diff --git a/with-location.cabal b/with-location.cabal
--- a/with-location.cabal
+++ b/with-location.cabal
@@ -1,9 +1,9 @@
--- This file has been generated from package.yaml by hpack version 0.10.0.
+-- This file has been generated from package.yaml by hpack version 0.11.0.
 --
 -- see: https://github.com/sol/hpack
 
 name:                   with-location
-version:                0.0.0
+version:                0.1.0
 synopsis:               Use ImplicitParams-based source locations in a backward compatible way
 category:               Data
 homepage:               https://github.com/sol/with-location#readme
@@ -22,12 +22,22 @@
   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
+
+test-suite spec
+  type: exitcode-stdio-1.0
+  main-is: Spec.hs
+  hs-source-dirs:
+      test
+  ghc-options: -Wall
+  build-depends:
+      base == 4.*
+    , hspec
+    , with-location
+  other-modules:
+      Data.WithLocationSpec
   default-language: Haskell2010
