mirror of
https://github.com/github/semantic.git
synced 2024-12-21 13:51:44 +03:00
Rename TVar to Var.
This commit is contained in:
parent
e011a71835
commit
f8096013f9
@ -14,7 +14,7 @@ data Type
|
||||
| String -- ^ Primitive string type.
|
||||
| Unit -- ^ The unit type.
|
||||
| Type :-> Type -- ^ Binary function types.
|
||||
| TVar TName -- ^ A type variable.
|
||||
| Var TName -- ^ A type variable.
|
||||
| Product [Type] -- ^ N-ary products.
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
@ -26,8 +26,9 @@ unify :: MonadFail m => Type -> Type -> m Type
|
||||
unify Int Int = pure Int
|
||||
unify Bool Bool = pure Bool
|
||||
unify (a1 :-> b1) (a2 :-> b2) = (:->) <$> unify a1 a2 <*> unify b1 b2
|
||||
unify (TVar _) b = pure b
|
||||
unify a (TVar _) = pure a
|
||||
-- FIXME: this should be constructing a substitution.
|
||||
unify (Var _) b = pure b
|
||||
unify a (Var _) = pure a
|
||||
-- FIXME: this can succeed incorrectly for lists of inequal length.
|
||||
unify (Product as) (Product bs) = Product <$> for (zip as bs) (uncurry unify)
|
||||
unify t1 t2 = fail ("cannot unify " ++ show t1 ++ " with " ++ show t2)
|
||||
|
@ -66,7 +66,7 @@ instance ( Alternative m
|
||||
let params = toList (foldMap freeVariables functionParameters)
|
||||
tvars <- for params $ \name -> do
|
||||
a <- alloc name
|
||||
tvar <- TVar <$> fresh
|
||||
tvar <- Var <$> fresh
|
||||
assign a tvar
|
||||
pure (name, a, tvar)
|
||||
|
||||
|
@ -60,7 +60,7 @@ instance ( MonadFail m
|
||||
opTy <- recur pure callFunction
|
||||
tvar <- fresh
|
||||
inTys <- traverse (recur pure) callParams
|
||||
_ :-> outTy <- opTy `unify` (Type.Product inTys :-> TVar tvar)
|
||||
_ :-> outTy <- opTy `unify` (Type.Product inTys :-> Var tvar)
|
||||
yield outTy
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user