我只是想看到一个随机数。因此,这里有一个直接从文档中摘出的Random库的示例。我期望
编译器错误显示了两个类型不匹配问题:
我在这里缺少什么?
Random.generate
接受一个生成器和一个种子,并返回一个包含随机值和新种子的元组,如下所示:
generate : Generator a -> Seed -> (a, Seed)
-- Main.elm
import Random
seed0 = Random.initialSeed 31415
randomNumber = Random.generate (Random.int 0 10) seed0
main =
-- print result of randomNumber here
编译器错误显示了两个类型不匹配问题:
-- TYPE MISMATCH ---------------------------------------------------- -----------
The 2nd argument to function `generate` is causing a mismatch.
5| Random.generate (Random.int 0 10) seed0
^^^^^
Function `generate` is expecting the 2nd argument to be:
Random.Generator a
But it is:
Random.Seed
The 1st argument to function `generate` is causing a mismatch.
5| Random.generate (Random.int 0 10) seed0
^^^^^^^^^^^^^^^
Function `generate` is expecting the 1st argument to be:
a -> b
But it is:
Random.Generator Int
我在这里缺少什么?