GHC includes span information in compiler errors, but not in a format suitable for vim:

src/Jacinda/Backend/TreeWalk.hs:319:58: error: • The constructor ‘TyArr’ should have 3 arguments, but has been given 4 • In the pattern: TyArr _ _ (TyArr _ (TyApp _ (TyB _ TyStream) _)) _ In the pattern: TyArr _ _ (TyArr _ _ (TyArr _ (TyApp _ (TyB _ TyStream) _)) _) In the pattern: TBuiltin (TyArr _ _ (TyArr _ _ (TyArr _ (TyApp _ (TyB _ TyStream) _)) _)) Fold | 319 | eWith re i (EApp _ (EApp _ (EApp _ (TBuiltin (TyArr _ _ (TyArr _ _ (TyArr _ (TyApp _ (TyB _ TyStream) _)) _)) Fold) op) seed) stream) = foldWithCtx re i op seed stream | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

We can handle this with awk (in fact, vim ships with mve.awk, a script to do something similar for C compilers), viz.

BEGIN { FS="\|" }

/ *\^+/ { p=match($2, "\^+") colstart=RSTART-1 col=colstart+RLENGTH printf("%d-%d\n", colstart, col) }

On the above example, this gives

58-108

Since this is a nontrivial (useful) demonstration of awk, I figured I would try something similar with my own jacinda:

:set fs:=/\|/;

fn printSpan(str) := let val p := match str /\^+/ val str := option '(none)' (sprintf '%i-%i') p in str end;

printSpan¨{% / *\^+/}{`2}

This avoids the strangeness of setting RSTART and RLENGTH (global variables) after a function call (match), instead returning multiple values with a tuple.