我是Purescript的幼稚者,因此在使用基于Purescript的框架之一时遇到一个非常基本的问题。
我正在使用PrestoDOM
,我想知道如何使用mapWithIndex
程序包中的Data.Array
函数。我尝试过以下操作,
import Data.Array (mapWithIndex)
...
(mapWithIndex
(\(item index) -> // want to use both item and its index through loop
textView [
width MATCH_PARENT
, height WRAP_CONTENT
, text item
, visibility index > 0 ? VISIBLE : GONE
]
)
data
)
...
但我收到此错误:
Unable to parse module:
unexpected [
expecting indentation at column 1 or end of input
我知道此错误直接来自我对mapWithIndex
的错误使用。
我终于可以解决问题了。错误使用mapWithIndex-参数顺序。
(mapWithIndex
(\index item ->
textView [
width MATCH_PARENT
, height WRAP_CONTENT
, text item
, visibility index > 0 ? VISIBLE : GONE
]
)
data
)