本文介绍了即使启用了DeriveGeneric,派生Generic也不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试遵循Beam Haskell库的教程: tathougies.github.io/beam/tutorials/tutorial1/
I'm trying to follow the tutorial for the Beam Haskell library: 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语言编译指示.
Note that the DeriveGeneric language pragma is present.
我在这里想念什么?
构建环境:
- 堆叠lts-11.9
- Linux
{-# LANGUAGE #-}声明需要放在文件的最顶部,在module声明之前.
A {-# LANGUAGE #-} declaration needs to go at the very top of the file, before the module declaration.
更多推荐
即使启用了DeriveGeneric,派生Generic也不起作用
发布评论