即使启用了DeriveGeneric,派生Generic也不起作用

编程入门 行业动态 更新时间:2024-10-09 07:23:06
本文介绍了即使启用了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也不起作用

本文发布于:2023-10-26 06:51:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1529394.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:也不   DeriveGeneric   Generic

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!