khibino / haskell-relational-record

This repository includes a joined query generator based on typefull relational algebra, and mapping tools between SQL values list and Haskell record type.
234 stars 36 forks source link

GHC 7.10.1 does not compile relational-schemas #13

Closed kazu-yamamoto closed 9 years ago

kazu-yamamoto commented 9 years ago
src/Database/Relational/Schema/DB2Syscat/Tabconst.hs:25:3:
    Illegal variable name: ‘type’
    When splicing a TH declaration:
      data Tabconst
    = Tabconst {constname :: !GHC.Base.String,
                tabschema :: !GHC.Base.String,
                tabname :: !GHC.Base.String,
                type :: !GHC.Base.String,
                enforced :: !GHC.Base.String}
    deriving (Show)
yuga commented 9 years ago

The "type" is derived from a column name of the "Tabconst" table.

GHC prior to 7.10 permitted a record field to have a name that has a collision with the reserved identifiers in Haskell if the field are generated by TH. We cannot use such a record field without qualifier, but in writing code with HRR, we always use it with qualified name. That restriction was not a problem.

GHC 7.10 got not to permit such record fields even derived from TH. If a database table has a column that is the same name with a reserved identifier, compilation error occurs.

HRR has to rename automatically, or has to provide an interface so that programmer can change to arbitrary name.

https://github.com/ghc/ghc/blob/ghc-7.8/compiler/hsSyn/Convert.lhs#L1058 https://github.com/ghc/ghc/blob/ghc-7.10/compiler/hsSyn/Convert.hs#L1142 https://github.com/ghc/ghc/blob/ghc-7.10/compiler/basicTypes/Lexeme.hs#L118

yuga commented 9 years ago

I committed the code to enable GHC 7.10.1 compile relational-schemas. This simply rename variables that conflict with the reserved identifiers.

Refer the following commits in ghc-710 branch. a8557ee05a857dbcd05dc0e777429702336be9d2 a59267ce2c9e52b1c8c4369b1b453e69d9eb3372

kazu-yamamoto commented 9 years ago

Confirmed. Let's release new versions.

yuga commented 9 years ago

@khibino Is this fix acceptable to you? If so, I will merge it with master branch and bump up version of names-th.

kazu-yamamoto commented 9 years ago

Let's release the next version ASAP.

kazu-yamamoto commented 9 years ago

FYI: https://github.com/hdbc/hdbc-sqlite3/pull/15

khibino commented 9 years ago

Merged this fix. Thanks!

khibino commented 9 years ago

This is fixed version. http://hackage.haskell.org/package/names-th-0.1.0.1