[Haskell-cafe] Template Haskell sugar / spliceing in
automatically ?
Derek Elkins
derek.a.elkins at gmail.com
Sat Jun 14 19:24:26 EDT 2008
On Sat, 2008-06-14 at 23:06 +0200, Marc Weber wrote:
> Hi, I've been thinking about template haskell sugar lately.
>
> Some cool libraries are there such as metaHDBC or the template haskell
> printf library.
>
> However they all have one thing in common:
>
> $(printf "...") a b c
>
> $(runStmt "INSERT INTO ( ) VALUES ( ?, ?, ? )" ) 2 3 4
>
>
> Would it make sense to automatically splice those functions?
>
> {-# auto-splice: runStmt, printf #-}
>
> So that you can just use
> printf "..." a b c
> and
> runStmt "INSERT INTO ( ) VALUES ( ?, ?, ? )" 2 3 4
> without $() ?
>
> Would this be convinient?
I've been iffy about this since TH was first created. It would
certainly be more convenient, but it starts running into some unpleasant
issues. Admittedly, most of these issues are issues of expectations,
but still.
One example from the CL/Scheme world, is that these macros wouldn't be
proper functions, so e.g. 'map printf' wouldn't work or wouldn't mean
the same thing, 'let formatString = "%s" in printf formatString'
wouldn't work or wouldn't mean the same thing (thus being a violation of
referential transparency, at least at a superficial level).
Let's say we have a function 'mydo' that turns an applicative expression
into one using monadic style. Then something like
foo = runState (mydo (inc + inc)) 0
brings back some of the issues of programming in an impure language.
Currently, I'm still leaning toward the more explicit syntax.
More information about the Haskell-Cafe
mailing list