git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
在这个haskell程序中,我启用了mpsGeneric开关,该程序的结果是:
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE QuasiQuotes #-}
module Main
where
import Database.Persist.Sql
import Database.Persist.TH
share
[mkPersist
sqlSettings
{ mpsGeneric = True
, mpsPrefixFields = False
, mpsEntityJSON = Just EntityJSON
{ entityToJSON = 'keyValueEntityToJSON
, entityFromJSON = 'keyValueEntityFromJSON
}
, mpsGenerateLenses = False
}
, mkMigrate "abc"]
[persistLowerCase|
Test
a String
|]
main :: IO ()
main = do
print $ (toSqlKey 1 :: TestId) /= (toSqlKey 1 :: TestId)
print $ (toSqlKey 1 :: TestId) == (toSqlKey 1 :: TestId)
print $ (toSqlKey 1 :: TestId) /= (toSqlKey 2 :: TestId)
print $ (toSqlKey 1 :: TestId) == (toSqlKey 2 :: TestId)
如果禁用mpsGeneric,结果为:
True
True
False
False
看来,上面的Eq实例已被打破。 我用
测试程序True
False
False
True
此"功能"当我运行以下代码时,我整整一个下午都要杀了我:
persistent of version 2.2.4.1
persistent-template of version 2.1.6