1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 05:11:44 +03:00

Take a stab at typechecking.

This commit is contained in:
Patrick Thomson 2018-03-16 17:07:53 -04:00
parent 6a5c3084ad
commit de4c3e5f8a
3 changed files with 5 additions and 0 deletions

View File

@ -48,6 +48,7 @@ letrec name body = do
instance (MonadFail m, LocationFor value ~ Precise, MonadHeap value m) => MonadAddressable Precise value m where instance (MonadFail m, LocationFor value ~ Precise, MonadHeap value m) => MonadAddressable Precise value m where
deref = derefWith (maybeM uninitializedAddress . unLatest) deref = derefWith (maybeM uninitializedAddress . unLatest)
alloc _ = do alloc _ = do
-- Compute the next available address in the heap, then write an empty value into it.
addr <- fmap (Address . Precise . heapSize) getHeap addr <- fmap (Address . Precise . heapSize) getHeap
addr <$ modifyHeap (heapInit addr mempty) addr <$ modifyHeap (heapInit addr mempty)

View File

@ -261,6 +261,9 @@ instance (Alternative m, MonadEnvironment Type m, MonadFail m, MonadFresh m, Mon
rational _ = pure Type.Rational rational _ = pure Type.Rational
multiple = pure . Type.Product multiple = pure . Type.Product
array = pure . Type.Array array = pure . Type.Array
klass _ _ = pure Object
objectEnvironment _ = pure mempty
ifthenelse cond if' else' = unify cond Bool *> (if' <|> else') ifthenelse cond if' else' = unify cond Bool *> (if' <|> else')

View File

@ -20,6 +20,7 @@ data Type
| Var TName -- ^ A type variable. | Var TName -- ^ A type variable.
| Product [Type] -- ^ N-ary products. | Product [Type] -- ^ N-ary products.
| Array [Type] -- ^ Arrays. Note that this is heterogenous. | Array [Type] -- ^ Arrays. Note that this is heterogenous.
| Object -- ^ Objects. Once we have some notion of inheritance we'll need to store a superclass.
deriving (Eq, Ord, Show) deriving (Eq, Ord, Show)
-- TODO: À la carte representation of types. -- TODO: À la carte representation of types.