{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeOperators #-}
import qualified Data.ByteString.Lazy as BL
import Data.Csv (DefaultOrdered, FromRecord,
ToNamedRecord, ToRecord)
import Data.Generics
import Data.Proxy
import qualified Data.Text as T
import Network.HTTP.Client (newManager)
import Network.HTTP.Client.TLS (tlsManagerSettings)
import Servant.API
import Servant.Client
import Servant.CSV.Cassava
import System.Environment
data Cata = Cata
{
csvDate :: String,
csvOpen :: String,
csvHigh :: String,
csvLow :: String,
csvClose :: String,
csvVolume :: String,
csvExDividend :: String,
csvSplitRatio :: String,
csvAdjOpen :: String,
csvAdjHigh :: String,
csvAdjLow :: String,
csvAdjClose :: String,
csvAdjVolume :: String
} deriving (Show, Generic)
instance DefaultOrdered Cata
instance FromRecord Cata
instance ToNamedRecord Cata
instance ToRecord Cata
我编译上面的代码并得到以下错误:为什么?
$ stack ghc servantcsv.hs
[1 of 1] Compiling Main ( servantcsv.hs, servantcsv.o )
servantcsv.hs:34:21: error:
• Illegal deriving item ‘Generic’
• In the data declaration for ‘Cata’
|
34 | } deriving (Show, Generic)
| ^^^^^^^
GHC版本:ghc-8.4.3
答案 0 :(得分:6)
您要导入PP
而不是GHC.Generics
。您导入的内容确实具有类型Data.Generics
,但它不是类:
Generic
肯定不能成为“派生”子句的一部分。