是否有可能构建一个"持久"架构?

Ale*_*x R 10 haskell persistent

假设我有4个模块:Common,A,B和Main,我想要以下模式:

share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Common
  commonField Int
A
  commonId CommonId
  aField Int
B
  commonId CommonId
  bField Int
|]
Run Code Online (Sandbox Code Playgroud)

但是我希望将它分割为Common,A和B模块.然后,我希望Main依赖于所有这些并包含数据库逻辑.

我尝试了以下(忽略B)

-- module Common
share [mkPersist sqlSettings, mkMigrate "migrateCommon"] [persistLowerCase|
Common
  commonField Int
|]

-- module A
share [mkPersist sqlSettings, mkMigrate "migrateA"] [persistLowerCase|
A
  commonId CommonId
  aField Int
|]
Run Code Online (Sandbox Code Playgroud)

但是由此产生的迁移将外部约束从A移除到Common.

persistLowerCase在调用share之前尝试存储和连接quasiquoter 的结果,但这导致了一个关于CommonId不在范围内的类型错误.

我能想到的唯一其他解决方案是存储字符串,连接它们,并在其上调用quasiquoter,这似乎不太好.

有什么建议?