gpt4 book ai didi

types - 在 Elm 0.18 中公开的模块

转载 作者:行者123 更新时间:2023-12-04 06:20:34 25 4
gpt4 key购买 nike

我有一个类型的榆树模块,它由类型和类型别名 Foo、Bar 和 Baz 组成。当我像这样导出所有内容时,代码有效:
module Types exposing (..)
但是,如果我明确包含所有类型,代码就会中断。
module Types exposing (Foo, Bar, Baz)
消费文件上的 import 语句也是如此;两者都需要 exposing (..)
这两种方法有什么区别?

最佳答案

我最近才自己学习 Elm,但听起来好像因为您的一种类型( Msg )被定义为联合类型,您需要使用 Msg(..)导出此类型时的语法。

module Types exposing (Msg (..))

type Msg = FirstAction | SecondAction | ThirdAction

或者在导入联合类型的情况下。
import Types exposing (Msg (..))

请参阅 GitHub issue #968解释为什么联合类型需要这样做。

关于types - 在 Elm 0.18 中公开的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46136301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com