我不确定Haskell中是否有内置的Date类型,很难说,我找不到任何文档。
这是我的导入声明
import Data.Aeson (FromJSON (..), ToJSON (..), Value, genericParseJSON, genericToJSON) import Data.Aeson.Types (Options (..), defaultOptions) import Data.Function ((&)) import Data.List (stripPrefix) import qualified Data.Map as Map import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T import GHC.Generics (Generic)这是有问题的一行
productionEntryProductionDate :: Date这是我在尝试运行stack build时遇到的错误
Not in scope: type constructor or class `Date'
我的代码来自我从一些Swagger 2.0 YAML生成的Web API。
我是Haskell的新手,所以如果您需要更多信息,请告诉我。
I am not sure if there is a built in Date type in Haskell or not, it is hard to tell and I can find no documentation.
Here are my import statements
import Data.Aeson (FromJSON (..), ToJSON (..), Value, genericParseJSON, genericToJSON) import Data.Aeson.Types (Options (..), defaultOptions) import Data.Function ((&)) import Data.List (stripPrefix) import qualified Data.Map as Map import Data.Maybe (fromMaybe) import Data.Text (Text) import qualified Data.Text as T import GHC.Generics (Generic)Here is the line in question
productionEntryProductionDate :: DateAnd here is the error I get when trying to run stack build
Not in scope: type constructor or class `Date'
The code I have was from a Web API I generated from some Swagger 2.0 YAML.
I am fairly new to Haskell, so if you need more info please let me know.
最满意答案
Date不是Haskell中的标准类型。 您可以定义自己的,也可以从时间库中使用Day 。 无论哪种方式,您都需要自己定义Aeson实例。 时间库有一个parseTimeM函数可以为你完成工作,但你仍然需要实例声明。
更正 :事实证明,Aeson已经拥有Day和UTCTime类型的实例。
Date is not a standard type in Haskell. You can either define your own or you can use Day from the time library. Either way you will need to define the Aeson instances for it yourself. The time library has a parseTimeM function which can do the work for you, but you still need the instance declarations.
Correction: it turns out that Aeson already has instances for both Day and UTCTime types.
更多推荐
发布评论