yesodweb / yesodweb/persistent
Documentation for `Database.Persist.TH` should clearly state what extensions must be enabled
Nobody has claimed this yet.
- Dominant language
- Haskell
- Stars
- 486
- Forks
- 306
- PR merge metrics
- No merged PRs in 30d
Description
The extensions needed for code that uses Database.Persist.TH to successfully work have changed over the versions -- breaking changes, since previously-compiling code will now not compile, unless they are added -- but this isn't clearly documented in the API documentation for that module, nor is it obvious in which versions the changes were introduced. (Relevant, if supporting users who might be using different versions of the persistent packages.)
The changelog for persistent-template mentions some, but not all, of the breaking changes (here).
The following script will fail with compilation errors:
#!/usr/bin/env stack
-- stack --resolver lts-15.16 script --verbosity info --package monad-logger --package persistent --package persistent-template --package persistent-postgresql --package mtl --package text
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
import Database.Persist.TH
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Person
name String
age Int Maybe
deriving Show
|]
main :: IO ()
main = print "done"
-- but if we add the following lines, then it runs with no problem:
{-# LANGUAGE CPP #-}
#if MIN_VERSION_persistent_template(2,7,2)
{-# LANGUAGE UndecidableInstances #-}
#endif
#if MIN_VERSION_persistent_template(2,8,0)
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StandaloneDeriving #-}
#endif
Since this is a breaking change, it should be clearly documented in the API and the changelog. (And it wouldn't hurt to update this also in the example given at the top of the page from the Yesod book, which the persistent-template README links to.)
Since this is a documentation bug, I don't know that my environment is relevant, but FWIW, it's linked in the gist here.
The script that compiles is here, and the one that doesn't is here. In the absence of module documentation stating otherwise, I'd expect them both to compile.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the Database.Persist.TH API documentation alongside persistent-template/ChangeLog.md and its README, then compare the compiling and failing scripts linked in the issue. Trace which persistent-template versions introduced the required extensions and update the API documentation and changelog accordingly. Check the linked Yesod book example and README example so the documented usage is consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100