Add a re-entrant haskell template.

This one differs from the old one in that it's safe in the presence of multiple
contexts at the same time where function pointers may be different (which can
happen on some systems).