Skip to content

Commit

Permalink
Fix displaying hover kind infos for types
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyShiue committed Aug 20, 2024
1 parent 78453b3 commit 0f51fdb
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ main = do
case mode of
ModeHelp -> putStrLn $ usageInfo usage options
ModeLSP -> do
_ <- runOnStdio "/Users/vince/Documents/gcl-vscode/server_log.txt"
_ <- runOnStdio "/Users/andy/Desktop/log.txt"
return ()
ModeDev -> do
_ <- runOnPort port
Expand Down
10 changes: 5 additions & 5 deletions src/GCL/Type.hs
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ collectTypeDefns typeDefns = do
let sub = Map.fromList . zip tyParamNames $ freshNames
let sub' = Map.fromList . zip tyParamNames $ TMetaVar <$> freshNames <*> pure NoLoc
let retTy = formTy (TData tyName' (locOf tyName')) (TMetaVar <$> tyParamNames <*> pure NoLoc)
let ty = subst sub' $ wrapTFunc (TVar <$> params <*> pure (locOf params)) retTy
let ty = subst sub' $ wrapTFunc params retTy
-- Here, we collect the patterns.
let pat = (conName, subst sub' retTy, TVar <$> params <*> pure (locOf params)) -- TODO: This is likely incorrect because I just want to make things work now carelessly.
let pat = (conName, subst sub' retTy, params)
modify (\(freshState, typeDefnInfos, origInfos, pats) -> (freshState, typeDefnInfos, origInfos, pat : pats))
-- Here, we enter the world for infering kinds.
(_kind, env'') <- inferKind (renameKindEnv sub env') ty
Expand Down Expand Up @@ -524,15 +524,15 @@ instance Elab Program where
instance Elab Definition where
elaborate (TypeDefn name args ctors loc) env = do
let m = Set.fromList args
mapM_ (\(TypeDefnCtor _ ns) -> mapM_ (scopeCheck m) ns) ctors
mapM_ (\(TypeDefnCtor _ ts) -> mapM_ (scopeCheck m) ts) ctors
ctors' <- mapM (\ctor -> do
(_, typed, _) <- elaborate ctor env
return typed
) ctors
return (Nothing, T.TypeDefn name args ctors' loc, mempty)
where
scopeCheck :: MonadError TypeError m => Set.Set Name -> Name -> m ()
scopeCheck ns n = if Set.member n ns then return () else throwError $ NotInScope n
scopeCheck :: MonadError TypeError m => Set.Set Name -> Type -> m ()
scopeCheck ns t = mapM_ (\n -> if Set.member n ns then return () else throwError $ NotInScope n) (freeVars t)
elaborate (FuncDefnSig name ty maybeExpr loc) env = do
expr' <- mapM (\expr -> do
(_, typed, _) <- elaborate expr env
Expand Down
2 changes: 1 addition & 1 deletion src/Syntax/Abstract/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ data Definition =
deriving (Eq, Show)

-- constructor of type definition
data TypeDefnCtor = TypeDefnCtor Name [Name]
data TypeDefnCtor = TypeDefnCtor Name [Type]
deriving (Eq, Show)

--------------------------------------------------------------------------------
Expand Down
4 changes: 3 additions & 1 deletion src/Syntax/Concrete/Instances/ToAbstract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ instance ToAbstract Definition [A.Definition] where
return [A.FuncDefn name $ wrapLam args body']

instance ToAbstract TypeDefnCtor A.TypeDefnCtor where
toAbstract (TypeDefnCtor c ns) = return $ A.TypeDefnCtor c ns
toAbstract (TypeDefnCtor c tys) = do
tys' <- mapM toAbstract tys
return $ A.TypeDefnCtor c tys'

--------------------------------------------------------------------------------
-- | Declaraion
Expand Down
2 changes: 1 addition & 1 deletion src/Syntax/Concrete/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ data Definition
| FuncDefn Name [Name] (Token "=") Expr
deriving (Eq, Show)

data TypeDefnCtor = TypeDefnCtor Name [Name] deriving (Eq, Show)
data TypeDefnCtor = TypeDefnCtor Name [Type] deriving (Eq, Show)

--------------------------------------------------------------------------------
-- | Declaration
Expand Down
2 changes: 1 addition & 1 deletion src/Syntax/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ definition = choice [try funcDefnSig, typeDefn, funcDefnF]
typeDefn = TypeDefn <$> tokenData <*> upper <*> many lower <*> tokenEQ <*> sepByGuardBar typeDefnCtor

typeDefnCtor :: Parser TypeDefnCtor
typeDefnCtor = TypeDefnCtor <$> upper <*> many identifier
typeDefnCtor = TypeDefnCtor <$> upper <*> many type'

definitionBlock :: Parser DefinitionBlock
definitionBlock = DefinitionBlock <$> tokenDeclOpen <*> sepByAlignmentOrSemi definition <*> tokenDeclClose
Expand Down
2 changes: 1 addition & 1 deletion src/Syntax/Typed/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data Definition
| FuncDefn Name Expr
deriving (Eq, Show)

data TypeDefnCtor = TypeDefnCtor Name [Name]
data TypeDefnCtor = TypeDefnCtor Name [Type]
deriving (Eq, Show)

data Declaration
Expand Down

0 comments on commit 0f51fdb

Please sign in to comment.