- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
msg) -> Cmd a -> Cmd -6ren">
Elm 文档没有给出示例用法,因此很难理解类型规范的含义。在几个地方,我看到“a”用作参数标识符,例如 Platform.Cmd :
map : (a -> msg) -> Cmd a -> Cmd msg
Cmd.map
?
最佳答案
这是 Elm Guide about reading Types Annotations 的一部分:
> [ "Alice", "Bob" ]
[ "Alice", "Bob" ] : List String
> [ 1.0, 8.6, 42.1 ]
[ 1.0, 8.6, 42.1 ] : List Float
> []
[] : List a
In the first case, we have a List filled with String values. In the second, the List is filled with Float values. In the third case the list is empty, so we do not actually know what kind of values are in the list. So the type List a is saying "I know I have a list, but it could be filled with anything". The lower-case a is called a type variable, meaning that there are no constraints in our program that pin this down to some specific type. In other words, the type can vary based on how it is used.
关于Elm 文档 - "a"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42703224/
我是一名优秀的程序员,十分优秀!