【发布时间】:2022-01-23 02:50:45
【问题描述】:
为什么这个函数需要一个整数列表?
Prelude> :t \xs->[(map $ uncurry(*)) (zip xs [1..n]) | n<-[1..(length xs)]]
\xs->[(map $ uncurry(*)) (zip xs [1..n]) | n<-[1..(length xs)]]
:: [Int] -> [[Int]]
当我将length xs 替换为固定值时,类型会发生变化并且不再那么严格:
Prelude> :t \xs->[(map $ uncurry(*)) (zip xs [1..n]) | n<-[1..100]]
\xs->[(map $ uncurry(*)) (zip xs [1..n]) | n<-[1..100]]
:: (Num b, Enum b) => [b] -> [[b]]
我的编译器是
$ ghci --version
The Glorious Glasgow Haskell Compilation System, version 8.8.4
【问题讨论】: