为什么我得到Haskell中解析输入错误

问题描述 投票:-3回答:2

我得到一个解析输入错误的和“E”。为什么是这样?固定我的压痕太

if not(true)
    then do g
            Node value e
    else return()
where
    f = false
    g = if f then Map.delete c children 
    e = Map.insert c (Node Nothing children) children

haskell
2个回答
4
投票

else的定义g部门也应包括在内。


4
投票

你得到一个解析错误,因为解析器期待看到else的上一行的if部分 - 而不是另一个变量的定义。每if需要在Haskell的else - 否则你会g的值是当f是假的?

一旦你已经修复了问题,你会得到你的do声明类型错误的原因有两个:在您的do声明的值不是一元(gMapNode value e是哪个类型定义Node构造函数);和类型的thenelse的不匹配:else部分有一些m ()键入Monad mthen部分有哪个类型Node是的一部分。

© www.soinside.com 2019 - 2024. All rights reserved.