yesodweb / shakespeare

Haml-like template files that are compile-time checked
http://www.yesodweb.com/book/shakespearean-templates
MIT License
136 stars 76 forks source link

Derive Lift instances wherever possible #252

Closed RyanGlScott closed 4 years ago

RyanGlScott commented 4 years ago

Many of shakespeare's Lift instances are equivalent to what would be generated by DeriveLift, so this patch switches them over to use deriving. For those instances that do not easily admit derived instances, I made sure that liftTyped was defined to avoid warnings when compiling with template-haskell-2.16.* (GHC 8.10). One example of such an instance is the Lift ShakespeareSettings instance, which relies on lifting Exps and Names from template-haskell. Since there is a canonical Lift Name orphan instance defined in the widely used, lightweight th-lift package, I decided to just add a dependency on that. This allows making the implementation of the Lift ShakespeareSettings instance slightly cleaner.

RyanGlScott commented 4 years ago

There were two instances that could conceivably be derived, but I wasn't bold enough to do so:

  1. The Lift ShakespeareSettings instance could be derived if we were to import the canonical orphan Lift Exp instance from the th-orphans library. Since th-orphans has a number of its own library dependencies, however, I wasn't sure if it was acceptable to incur a dependency on th-orphans.
  2. The Lift instances for Attr Resolved and Block Resolved could be derived if we were to define a canonical orphan instance for Builder in some library. (th-lift-instances seems like a good candidate.) I haven't investigated doing so yet, however.

These don't necessary need to hold up this PR, but I thought it worth noting as potential improvements in the future.