我有这样的文件结构:
--- Database.hs ---
data Database = ...
...
--- User.hs ---
import Database
addUser :: Update Database ()
...
--- Post.hs
import Database
addPost :: Update Database ()
...
问题是我需要在makeAcidic ''Database [...]
和User.hs
中调用Post.hs
以使其功能变为酸性,但makeAcidic
同时生成IsAcidic
Database
的实例所以GHC抱怨重复的实例声明。
答案 0 :(得分:5)
--- Database/Types.hs ---
data Database = ...
...
--- Database.hs ---
import Database.Types
import User
import Post
makeAcidic ''Database [addUser, addPost]
--- User.hs ---
import Database.Types
addUser :: Update Database ()
...
--- Post.hs ---
import Database.Types
addPost :: Update Database ()
...