
Ok, so I took the rule rewriting idea and added a preprocessor instead, that inserts 'assert's for you, currently just for head,tail and fromJust. This program, for example: module Main where import qualified Data.Map as M import Data.Maybe main = do print f f = let m = M.fromList [(1,"1") ,(2,"2") ,(3,"3")] s = M.lookup 4 m :: Maybe String in head ([] :: [()]) Fails with: $ ghc A.hs --make [1 of 1] Compiling Main ( A.hs, A.o ) Linking A ... $ ./A A: Maybe.fromJust: Nothing Add one import statement: import Debug.Trace.Location And recompile with the preprocessor: $ ghc A.hs --make -pgmF loch -F -no-recomp [1 of 1] Compiling Main ( A.hs, A.o ) Linking A ... And our fromJust is rewritten to a located fromJust: $ ./A A: A.hs:14:14-19: Maybe.fromJust: Nothing Currently this only works for fromJust, head and tail. Adding user-specified located functions should be trivial. The 'loch' preprocessor is in the darcs repo, now. http://www.cse.unsw.edu.au/~dons/code/loch/ Comments, suggestions? -- Don