Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.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
Haskell 分析错误(可能缩进不正确)_Haskell - Fatal编程技术网

Haskell 分析错误(可能缩进不正确)

Haskell 分析错误(可能缩进不正确),haskell,Haskell,我得到以下错误,任何人都可以解释我什么是错误的代码 105:0: parse error (possibly incorrect indentation) 代码如下: -- Type inference for expressions -- tyInf :: Gamma -> Exp -> TC (Exp, Type, Subst) tyInf g (Num n) = return (Num n, intTyCon, [([intId], intTyCon)]) tyInf g

我得到以下错误,任何人都可以解释我什么是错误的代码

105:0: parse error (possibly incorrect indentation)
代码如下:

-- Type inference for expressions
--
tyInf :: Gamma -> Exp -> TC (Exp, Type, Subst)
tyInf g (Num n) =  return (Num n, intTyCon, [([intId], intTyCon)])
tyInf g (Con tag[])   
  | tag == unitTag  = return (Con tag[],unitTyCon,[([unitId], unitTyCon)])
  | tag == falseTag = return (Con tag[], boolTyCon, [([boolId],boolTyCon)])
  | tag == trueTag  = return (Con tag[],boolTyCon, [([boolId],boolTyCon)])
  | otherwise       = error "unknown constructor"

tyInf g (Con tag [ e1, e2]) | tag == pairTag = do       
  return ( (Con tag [ e1, e1], (mkPairTy (tyInf g e1) (tyInf g e2)), 
    [([pairId], (mkPairTy (tyInf g e1) (tyInf g e2)))])

-- ---------------------------------------------------------------------
-- The type for a unifier. A value of this type maps free
-- type variables to real types.
--
-- You may change this type if you wish. The following is
-- one possible type, though not necessarily the best.
--
type Subst = [([TyVar], Type)] -- <--- This is line 105

-- --------------------------------------------------------------------
-- Unification
--
unify :: Type -> Type -> Subst
unify t1 t2 
  | t1 == t2  =  []
  | otherwise  =  [(tyVarsIn t1, t2)]
——表达式的类型推断
--
tyInf::Gamma->Exp->TC(Exp,Type,Subst)
tyInf g(Num n)=返回(Num n,intTyCon,[([intId],intTyCon)])
tyInf g(Con标签[])
|tag==unitTag=return(Con tag[],unitTyCon,[([unitId],unitTyCon)])
|标签==falseTag=return(Con标签[],boolTyCon,[([boolId],boolTyCon)])
|tag==trueTag=return(Con-tag[],boolTyCon,[([boolId],boolTyCon)])
|否则=错误“未知构造函数”
tyInf g(Con tag[e1,e2])| tag==pairTag=do
返回((Con标签[e1,e1],(mkPairTy(tyInf g e1)(tyInf g e2)),
[([pairId],(mkPairTy(tyInf g e1)(tyInf g e2)))]
-- ---------------------------------------------------------------------
--unifier的类型。此类型的值映射为自由值
--将变量类型转换为实类型。
--
--如果愿意,您可以更改此类型。以下是
--一种可能的类型,但不一定是最好的。
--
类型Subst=[([TyVar],type)]--类型->Subst
统一t1 t2
|t1==t2=[]
|否则=[(tyVarsIn t1,t2)]

将105之前的代码行快速复制并粘贴到一个编辑器中,该编辑器不会显示语法hilighting,表明您的PARAN不正确。请尝试以下操作:

 return ( (Con tag [ e1, e1], (mkPairTy (tyInf g e1) (tyInf g e2)),
      [([pairId], (mkPairTy (tyInf g e1) (tyInf g e2)))]))
请注意末尾的额外


您确实应该投入一些时间来设置您的开发环境。这是值得的。

嗯,你检查过那行缩进是否正确了吗?