patches for hsx, hjscript, and hsp plus work on an hsx quasi-quoter

7 views
Skip to first unread message

Jeremy Shaw

unread,
Apr 16, 2012, 7:05:31 PM4/16/12
to Niklas Broberg, Haskell Server Pages
Hello,

I have attached patches to hsx, hjscript, and hsp updating them to
work with GHC > 7, and also updating the maintainer email address and
the source web pages. I did not patch HJavaScript, or any of the other
packages to update the maintainer information. Also, I did not change
where 'darcs send' goes. I think you can only change that by editing
your account information on patch-tag.

Additionally, there are some extra patches to HSX. In HSX.Transform, a
number of locations had code like:

(var nothing_name)

But Nothing is a constructor not a variable. This has not been a
problem until now because the pretty-printer does not care, and so
everything just works out ok in the end.

However, if you use haskell-src-meta to translate the HSE AST to TH,
then you will get a compile-time splice error because TH does care. So
I patch that (hopefully correctly).

Additionally, I renamed transformExp to transformExpM, and exported a
new function:

> transformExp :: Exp -> Exp

Using this new function it is now easy to implement a HSX
quasi-quoter. I have attached a prototype and a demo that uses it.
(The demo also requires haskell-src-meta and happstack-hsp).

Once the new HSX is released, I can release a package like, hsx-qq. Or
we could put the QuasiQuoter in HSX itself. It does add a dependency
on haskell-src-meta though. Not sure if that matters or not.

Using the new quoter you can now do:

> html :: (XMLGenerator m) => XMLGenT m (HSX.XML m)
> html = [hsx| <p><% map toUpper "hello, world!" %></p> |]
>
> main :: IO ()
> main = putStrLn $ renderAsHTML $ evalIdentity html

GHCi>
<p
>HELLO, WORLD!</p
>

This has a few advantages over trhsx:

1. it does not require an external pre-processor to be installed and
findable. Nor does it require the odd looking {-# OPTIONS_GHC -F
-pgmFtrhsx #-} pragma
2. It should leave haddock comments intact
3. line numbers in error messages are possibly more correct
4. it ought to work better if you want to use literal XML inside
normal TH (though some Lift instances are likely required)
5. it will make hamlet users feel more at home

The external trhxs tool is useful as well. This is intended to
compliment not replace it.

- jeremy

hjscript-fixes-for-ghc7.dpatch
hsp-fixes-for-ghc7.dpatch
hsx-bug-fixes-and-export-transformExp.dpatch
HSXQQ.hs
Test.hs

dag.od...@gmail.com

unread,
Apr 16, 2012, 9:15:27 PM4/16/12
to haskell-se...@googlegroups.com, Niklas Broberg
On Tue, Apr 17, 2012 at 1:05 AM, Jeremy Shaw <jer...@n-heptane.com> wrote:

 1. it does not require an external pre-processor to be installed and
findable. Nor does it require the odd looking {-# OPTIONS_GHC -F
-pgmFtrhsx #-} pragma
 2. It should leave haddock comments intact
 3. line numbers in error messages are possibly more correct
 4. it ought to work better if you want to use literal XML inside
normal TH  (though some Lift instances are likely required)
 5. it will make hamlet users feel more at home

6. It will work in GHCi!

Thomas Hartman

unread,
Apr 16, 2012, 9:18:08 PM4/16/12
to haskell-se...@googlegroups.com, Niklas Broberg
> 3. line numbers in error messages are possibly more correct

This drove (drives) me nuts. Is it really fixed? I have to check it out...

> --
> You received this message because you are subscribed to the Google Groups
> "Haskell Server Pages" group.
> To post to this group, send email to haskell-se...@googlegroups.com.
> To unsubscribe from this group, send email to
> haskell-server-p...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/haskell-server-pages?hl=en.

--
--
_____________________
Thomas Hartman
MarketPsych LLC
MarketPsy Capital  LLC
2400 Broadway, Suite 220
Santa Monica, CA, USA
Tel:  +1.310.573.8523
______________________

This e-mail message and any attachments may contain information that
is confidential, proprietary or privileged, and is for the named
person’s use only.  No confidentiality or privilege is waived or lost
by any mistransmission.  If you are not the intended recipient or
agent responsible for delivering it to the intended recipient, you are
hereby notified that any dissemination, distribution, copying or other
use of this message or its attachments is strictly prohibited.  If you
have received this message in error, please notify us immediately and
destroy all copies of this message and attachments without disclosing
the contents to anyone.  Neither this message nor any information
included herein constitute an offer to sell or the solicitation of an
offer to buy any securities or investment product, or legal, tax,
accounting, or investment advice.

Reply all
Reply to author
Forward
0 new messages