Haskell-尽管在 stack.yaml 中输入,但堆栈无法构建具有 DateTime 依赖项的项目

Haskell-Stack failing to build project with DateTime dependency despite entry in stack.yaml

所以我试图添加这个包:datetime-0.3.1 并且我添加了我 认为 是 stack.yaml 文件中的正确引用。我尝试使用堆栈求解器,但它似乎不再存在。我还寻找了一些等同于 pip 的东西,所以我可以做 stack install datetime-0.3.1 或类似的东西,但这似乎不是 stack 做的事情。

代码:

module FhirDataTypes (
    FhirId (..),
    toFhirId
) where

import Data.Maybe (Maybe(..))
import Data.List (length)
import Coding as Coding
import Data.Decimal
import FhirUri (FhirUri(..))
import FhirString (FhirString(..))
import SimpleQuantity (SimpleQuantity(..))
import Data.DateTime

newtype FhirId = FhirId FhirString deriving (Show)

toFhirId :: FhirString -> Maybe FhirId
toFhirId fs@(FhirString s)
    | length s > 64 = Nothing
    | otherwise = Just $ FhirId fs

data Money = Money  { value :: Decimal
                    , currency :: Code
}

data Range = Range  {   low :: SimpleQuantity
                    ,   high :: SimpleQuantity
}

data Ratio = Ratio  {   numerator :: Quantity
                    ,   denominator :: Quantity
}

data Period = Period    { start :: DateTime
                        , end :: DateTime
}

我遇到的错误:

PS C:\util\haskell\fhir-practice> stack build

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for fhir-practice-0.1.0.0:
DateTime needed, but the stack configuration has no specified version (no package with that name found, perhaps there is a typo in
         a package's build-depends or an omission from the stack.yaml packages list?) needed since fhir-practice is a build target.

Some different approaches to resolving this:


Plan construction failed.

我的 stack.yaml 文件:

flags: {}
packages:
- .
extra-deps: 
- network-  uri-2.6.1.0@sha256:62cc45c66023e37ef921d5fb546aca56a9c786615e05925fb193a70bf0913690
- Decimal-0.4.2
- datetime-0.3.1
resolver: lts-13.24
  1. stack install 主要用于全局安装二进制文件,而不是 project-specific 包。

  2. 您可能想使用 time 包,而不是 datetime。因为前者是积极维护的。此外,在您的情况下,time 存在于 LTS-13.24 中,因此您不需要将其添加到 extra-deps。 extra-deps 字段仅适用于您的解析器中不存在的依赖项(包括传递性依赖项)。