Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
List Haskell:Glade条目的列表理解_List_Haskell_List Comprehension_Glade - Fatal编程技术网

List Haskell:Glade条目的列表理解

List Haskell:Glade条目的列表理解,list,haskell,list-comprehension,glade,List,Haskell,List Comprehension,Glade,我想制作一个entries::Map(String->Entry),这样我就可以方便地按名称访问每个条目。为此,我有代码 Just xml ← xmlNew "blah.glade" ... entries ← fromList $ [(name,entry) | name <- entryList , entry <- xmlGetWidget xml castToEntry name] 我不明白为什么它会期待一份清单。有人能帮我吗?这是因为出于某种原

我想制作一个
entries::Map(String->Entry)
,这样我就可以方便地按名称访问每个条目。为此,我有代码

  Just xml ←  xmlNew "blah.glade"
  ...
  entries ← fromList $ [(name,entry) | name <- entryList 
      , entry <- xmlGetWidget xml castToEntry name]

我不明白为什么它会期待一份清单。有人能帮我吗?

这是因为
出于某种原因,我的ghc无法识别
,但我可以输入
←  改为fromList`fmap`mapM getEntryTuple entryList
。谢谢你的描述<代码>
位于
控件中。应用程序
   Couldn't match expected type `[t]' against inferred type `IO Entry'
    In the expression: xmlGetWidget xml castToEntry name
    In a stmt of a list comprehension:
        entry <- xmlGetWidget xml castToEntry name
    In the second argument of `($)', namely
        `[(name, entry) |
              name <- entryList, entry <- xmlGetWidget xml castToEntry name]'
let getEntry name = do entry <- xmlGetWidget xml castToEntry name
                       return (name, entry)
entries <- fromList <$> mapM getEntry entryList