with-location (empty) → 0.0.0
raw patch · 5 files changed
+98/−0 lines, 5 filesdep +basesetup-changed
Dependencies added: base
Files
- LICENSE +19/−0
- Setup.lhs +3/−0
- includes/with-location.h +16/−0
- src/Data/WithLocation.hs +27/−0
- with-location.cabal +33/−0
+ LICENSE view
@@ -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.
+ Setup.lhs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+> import Distribution.Simple+> main = defaultMain
+ includes/with-location.h view
@@ -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
+ src/Data/WithLocation.hs view
@@ -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
+ with-location.cabal view
@@ -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