[Haskell-beginners] exceptions and stacks

Karol Samborski edv.karol at gmail.com
Wed Nov 7 08:51:03 CET 2012

Hi Emmanuel!

Have you looked at
? With the loch-th package you can write your own head function like

{-# LANGUAGE TemplateHaskell #-}
module Main where

import Debug.Trace.LocationTH

myHead a = $check $ head a

and then something like myHead ([] :: [Char]) will print something like this:
test: test.hs:21:12-17: Prelude.head: empty list

In docs there is another useful function $failure that is "a
location-emitting error call".

Hope that helps.

More information about the Beginners mailing list