file-location

common functions that show file location information

https://github.com/gregwebs/FileLocation.hs

Version on this page:0.4.5.3
LTS Haskell 6.35:0.4.9.1
Stackage Nightly 2016-05-25:0.4.9
Latest on Hackage:0.4.9.1

See all snapshots file-location appears in

BSD-3-Clause licensed by Greg Weber
Maintained by greg@gregweber.info
This version can be pinned in stack with:file-location-0.4.5.3@sha256:7939adaede62fc9b606ff8814ee44318772d1946e919f6fd5b7075ab1371e885,2814

Module documentation for 0.4.5.3

  • Control
    • Control.Exception
      • Control.Exception.FileLocation
  • Debug
    • Debug.FileLocation
    • Debug.Util
  • FileLocation
    • FileLocation.LocationString

Common debugging/error/exception functions that give file location information

$(err "OH NO!")
main:Main main.hs:16:1 OH NO!

Notice how it displays package:module file:line:character

It exposes the functions err (error), undef (undefined), and trc (Debug.Trace.trace). All of these behave the same as their normal counterpart but also spit out a location.

Here is my favorite helper, debug, which is like trace but just show the value.

debug [1,2,3]
DEBUG: [1,2,3]
[1,2,3]

And The Template Haskell version.

$(dbg) [1,2,3]
DEBUG main:Main main.hs:1:3 [1,2,3]
[1,2,3]

Also there is a version of thrwIO that gives location information

($(thrwIO) $ AException) catch e -> putStrLn ("Caught " ++ show (e :: AException))
Caught AException "main:Main test/main.hs:25:6"

See module for a listing of all the functions with short descriptions, and the homepage for some more examples https://github.com/gregwebs/ErrorLocation.hs