Temlpate Haskell: [d| ... |]

[d| ... |], where the "..." is a list of top-level declarations; the quotation has type Q [Dec].
(http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell.htm...) Can someone elaborate on what a list means here? Neither declarations = [d| foo = "bar" bar = "foo" |] nor declarations = [d| [ foo = "bar" , bar = "foo" ] |] work. I'm trying to automatically generate a bunch of functions out of an xml file. -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.

On Fri, Oct 17, 2008 at 9:26 AM, Achim Schneider
[d| ... |], where the "..." is a list of top-level declarations; the quotation has type Q [Dec].
( http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell.htm... )
Can someone elaborate on what a list means here? Neither
declarations = [d| foo = "bar" bar = "foo" |]
nor
declarations = [d| [ foo = "bar" , bar = "foo" ] |]
work. I'm trying to automatically generate a bunch of functions out of an xml file.
Works for me. Note that -fth is needed.
-- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

"Philip Weaver"
On Fri, Oct 17, 2008 at 9:26 AM, Achim Schneider
wrote: [d| ... |], where the "..." is a list of top-level declarations; the quotation has type Q [Dec].
( http://www.haskell.org/ghc/docs/latest/html/users_guide/template-haskell.htm... )
Can someone elaborate on what a list means here? Neither
declarations = [d| foo = "bar" bar = "foo" |]
nor
declarations = [d| [ foo = "bar" , bar = "foo" ] |]
work. I'm trying to automatically generate a bunch of functions out of an xml file.
Works for me. Note that -fth is needed.
-fth doesn't make a difference here, I'm using -XTemplateHaskell with ghc 6.8.3 Now if I wasn't sure that it somehow should work ([d| ... |]'s type is Q [Dec], after all), I would write myself an concatM :: [m [a]] -> m [a] -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.

--- On Fri, 10/17/08, Achim Schneider
declarations = [d| foo = "bar" bar = "foo" |] -fth doesn't make a difference here, I'm using -XTemplateHaskell with ghc 6.8.3
The following lines, verbatim, pasted into a file, work for me with 6.8.3 with no command line options: {-# LANGUAGE TemplateHaskell #-} module TH where import Language.Haskell.TH declarations = [d| foo = "bar" bar = "foo" |] __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Robert Greayer
--- On Fri, 10/17/08, Achim Schneider
wrote: declarations = [d| foo = "bar" bar = "foo" |] -fth doesn't make a difference here, I'm using -XTemplateHaskell with ghc 6.8.3
The following lines, verbatim, pasted into a file, work for me with 6.8.3 with no command line options:
{-# LANGUAGE TemplateHaskell #-} module TH where import Language.Haskell.TH
declarations = [d| foo = "bar" bar = "foo" |]
Argh. Yes. They do. While I certainly am in favour of layout rules, I'm not in favour of one that gives raises an error if you don't indent the closing |] by at least one whitespace. declarations = [d| foo = "bar" bar = "foo" |] doesn't work, either, as declarations = [d| foo = "bar" bar = "foo" |] -- (c) this sig last receiving data processing entity. Inspect headers for copyright history. All rights reserved. Copying, hiring, renting, performance and/or quoting of this signature prohibited.
participants (3)
-
Achim Schneider
-
Philip Weaver
-
Robert Greayer