英文:
DeriveDataTypable in multiple files with cabal
问题
我的Haskell项目有多个文件,与GHC兼容并且运行良好。
但是当我将它移到Cabal时,我遇到了问题无法创建一个派生实例...: 您需要DeriveDataTypeable来为这个类派生一个实例
。
找到了一个解决方案,使用{-# LANGUAGE DeriveDataTypeable #-}
。(来自这个问题) 它有助于第一个代码文件。但是当Cabal继续处理第二个文件时,同样的错误发生。我使用了相同的编译指令,但它并没有帮助。
英文:
My Haskell project with multiple files complies with GHC and runs well.
But when I moved it to Cabal I ran into problem Can't make a derived instance of ...: You need DeriveDataTypeable to derive an instance for this class
.
Found a solution to use {-# LANGUAGE DeriveDataTypeable #-}
. (From this question) It helped with first code file. But the same error happens when cabal proceeds to second file. I used same pragma but it just does not help.
答案1
得分: 3
从你的截图我猜测你有这样的代码:
module TelegramClient where
{-# LANGUAGE DeriveDataTypeable #-}
import ...
.
.
.
但扩展应该放在文件的顶部:
{-# LANGUAGE DeriveDataTypeable #-}
module TelegramClient where
import ...
.
.
.
我之所以这么说是因为你的截图从第二行开始,我没有看到任何模块头,所以我猜测模块头应该在第一行。顺便说一下,这也是为什么使用代码块而不是截图很重要的原因。
英文:
from your capture I guess you have this
module TelegramClient where
{-# LANGUAGE DeriveDataTypeable #-}
import ...
.
.
.
but extensions should be at the top of the file
{-# LANGUAGE DeriveDataTypeable #-}
module TelegramClient where
import ...
.
.
.
I say so because your capture starts at second line, and I don't see any module header, so I guess the module header is on the first line. That's why is important to use code block instead of screenshots by the way
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论