#4129: Template haskell API makes inconsistent use of [Q Dec], Q [Dec] and Q Dec
---------------------------------+------------------------------------------
Reporter: lilac | Owner:
Type: proposal | Status: new
Priority: normal | Component: Template Haskell
Version: 6.12.1 | Keywords:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Template haskell declaration quotations produce Q [Dec]. However, all of
the functions for consuming lists of declarations in Language.Haskell.TH
accept only [Q Dec]. This results in some pretty awkward constructs, such
as:
{{{
instanceD ctxt inst =<< (fmap.fmap) return [d|
foo a = a * 42
|]
}}}
[Note also that |] must be indented in the above example (otherwise GHC
gives an unhelpful error).]
Equally problematically, the functions which /create/ declarations all
produce Q Dec, but declaration splices want Q [Dec], resulting in the need
to write ugly code or drop into a do-block.
My modest proposal to fix all this is to have only a single type used for
declarations within the world of TH. The obvious most-general choice for
this type is Q [Dec]. So:[[br]]
1) Change all [DecQ] arguments to Q [Dec][[br]]
2) Change all DecQ return types to Q [Dec][[br]]
3) Add "<++> = liftM2 (++)" for easy combining of Q [Dec] to
Language.Haskell.TH.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4129>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs