Skip to content

Derive Lift instances wherever possible#252

Merged
snoyberg merged 1 commit intoyesodweb:masterfrom
RyanGlScott:master
Jun 18, 2020
Merged

Derive Lift instances wherever possible#252
snoyberg merged 1 commit intoyesodweb:masterfrom
RyanGlScott:master

Conversation

@RyanGlScott
Copy link
Copy Markdown
Contributor

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.

Many of `shakespeare`'s `Lift` instances are equivalent to what would
be generate 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 `Exp`s and `Name`s 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
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Member

@snoyberg snoyberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I'll hold off on the additional dependency for the moment, but I'm not strongly opposed to including it in the future

@snoyberg snoyberg merged commit dec3ecf into yesodweb:master Jun 18, 2020
snoyberg added a commit that referenced this pull request Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants