解析错误(可能是错误的缩进)

时间:2011-10-24 05:09:15

标签: 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 (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)]

1 个答案:

答案 0 :(得分:2)

将105行之前的代码行快速复制并粘贴到执行语法高亮显示的编辑器中,显示您的段落不会加起来。试试这个:

 return ( (Con tag [ e1, e1], (mkPairTy (tyInf g e1) (tyInf g e2)),
      [([pairId], (mkPairTy (tyInf g e1) (tyInf g e2)))]))

请注意最后的额外)

您真的应该投入一些时间来设置开发环境。它得到了回报。