我正在尝试遵循 Beam Haskell 库的教程:https://tathougies.github.io/beam/tutorials/tutorial1/
module Lib
( someFunc
) where
{-# LANGUAGE
DeriveGeneric
, GADTs
, OverloadedStrings
, FlexibleContexts
, FlexibleInstances
, TypeFamilies
, TypeApplications
#-}
import Database.Beam
import Database.Beam.Postgres
import GHC.Generics
import Data.Text (Text)
data UserT f
= User
{ _userEmail :: Columnar f Text
, _userFirstName :: Columnar f Text
, _userLastName :: Columnar f Text
, _userPassword :: Columnar f Text }
deriving Generic
someFunc :: IO ()
someFunc = putStrLn "someFunc"
这会导致以下错误:
• Can't make a derived instance of ‘Generic (UserT f)’:
You need DeriveGeneric to derive an instance for this class
• In the data declaration for ‘UserT’
|
27 | deriving Generic
| ^^^^^^^
请注意,存在 DeriveGeneric 语言编译指示。
我在这里缺少什么?
构建环境:
- 堆栈 lts-11.9
- Linux
最佳答案
{-# LANGUAGE #-}
声明需要位于文件的最顶部,位于 module
声明之前。
关于haskell - 即使 DeriveGeneric 打开,派生 Generic 也不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50314032/