2011-10-24 9 views
-1

次のエラーが表示されるので、コードに何が間違っているか説明してください。解析エラー(インデントが間違っている可能性があります)

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)] 
+2

その行が正しくインデントされているかどうかを確認しましたか? – MatrixFrog

答えて

2

前105へのコードの行のクイックコピー&ペーストの構文hilightingは、あなたのparansが加算されません示していないエディタに。これを試してみてください:

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

注最後に余分な)

開発環境のセットアップには、しばらく時間を費やす必要があります。それは報われる。

+0

お返事ありがとうございます – user1010130

関連する問題