yesodweb / yesodweb/persistent

Example in documentation for Database.Persist.Sql (in persistent 2.10.5.2) doesn't compile

Open
#1,092 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haskell
Stars
486
Forks
306
PR merge metrics
No merged PRs in 30d

Description

Environment:

  • Ubuntu 16.04, using stack 2.3.1
  • See gist here

The example code given for the function rawSql in the Haddock documentation for Database.Persist.Sql doesn't compile. (The relevant source file is this one.)

Here is the example from the documentation, pasted into a Stack script, which fails to compile.

Expected result
  • The script should run with no compilation errors. (Runtime errors will then occur if the example database cannot be connected to; but nevertheless, compilation should succeed.)
Actual result

Compilation fails with the error:

/home/phlummox/example.hs:23:1: error:
    Generating Persistent entities now requires the following language extensions:

DerivingStrategies
StandaloneDeriving
UndecidableInstances

Please enable the extensions by copy/pasting these lines into the top of your file:

{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE UndecidableInstances #-}
   |
23 | share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

And if that is fixed, with an "ambiguous occurrence" error:

/home/phlummox/example.hs:41:57: error:
    Ambiguous occurrence ‘liftSqlPersistMPool’
    It could refer to
       either ‘Database.Persist.Postgresql.liftSqlPersistMPool’,
              imported from ‘Database.Persist.Postgresql’ at /home/phlummox/example.hs:23:1-44
              (and originally defined in ‘persistent-2.10.5.2:Database.Persist.Sql.Run’)
           or ‘Main.liftSqlPersistMPool’,
              defined at /home/phlummox/example.hs:38:1
   |
41 | main = runStderrLoggingT $ withPostgresqlPool conn 10 $ liftSqlPersistMPool $ do
   |   

A fixed example, which actually does compile without error, is given here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with persistent/Database/Persist/Sql/Raw.hs at the rawSql documentation example and compare it with the compiling example-fixed-hs gist. Run the documented example as a Stack script; done means it compiles without errors, even if database connection runtime errors remain.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, postgresql
Domain
database, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.