Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update frontend to add support for MPTC and functional dependencies #75

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions curry-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ library
ghc-options: -Wall
build-depends:
Glob ==0.10.*
, aeson >=2.0 && <2.2
, aeson ==2.2.*
, async ==2.2.*
, base >=4.16 && <4.19
, bytestring ==0.11.*
, bytestring >=0.11 && <0.13
, bytestring-trie ==0.2.*
, co-log-core ==0.3.*
, containers ==0.6.*
, containers >=0.6 && <0.8
, curry-frontend
, data-default ==0.7.*
, directory ==1.3.*
, either >=5.0 && <6
, exceptions ==0.10.*
, extra ==1.7.*
, extra >=1.7 && <1.9
, filepath ==1.4.*
, lens >=5.1 && <5.3
, lsp ==2.7.*
Expand All @@ -90,7 +90,7 @@ library
, process >=1.6 && <2
, sorted-list ==0.2.*
, stm ==2.5.*
, text ==2.0.*
, text >=2.0 && <2.2
, text-rope ==0.2.*
, transformers >=0.5 && <0.7
, unliftio-core ==0.2.*
Expand All @@ -105,20 +105,20 @@ executable curry-language-server
ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall
build-depends:
Glob ==0.10.*
, aeson >=2.0 && <2.2
, aeson ==2.2.*
, async ==2.2.*
, base >=4.16 && <4.19
, bytestring ==0.11.*
, bytestring >=0.11 && <0.13
, bytestring-trie ==0.2.*
, co-log-core ==0.3.*
, containers ==0.6.*
, containers >=0.6 && <0.8
, curry-frontend
, curry-language-server
, data-default ==0.7.*
, directory ==1.3.*
, either >=5.0 && <6
, exceptions ==0.10.*
, extra ==1.7.*
, extra >=1.7 && <1.9
, filepath ==1.4.*
, lens >=5.1 && <5.3
, lsp ==2.7.*
Expand All @@ -128,7 +128,7 @@ executable curry-language-server
, process >=1.6 && <2
, sorted-list ==0.2.*
, stm ==2.5.*
, text ==2.0.*
, text >=2.0 && <2.2
, text-rope ==0.2.*
, transformers >=0.5 && <0.7
, unliftio-core ==0.2.*
Expand All @@ -144,20 +144,20 @@ test-suite curry-language-server-test
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
Glob ==0.10.*
, aeson >=2.0 && <2.2
, aeson ==2.2.*
, async ==2.2.*
, base >=4.16 && <4.19
, bytestring ==0.11.*
, bytestring >=0.11 && <0.13
, bytestring-trie ==0.2.*
, co-log-core ==0.3.*
, containers ==0.6.*
, containers >=0.6 && <0.8
, curry-frontend
, curry-language-server
, data-default ==0.7.*
, directory ==1.3.*
, either >=5.0 && <6
, exceptions ==0.10.*
, extra ==1.7.*
, extra >=1.7 && <1.9
, filepath ==1.4.*
, lens >=5.1 && <5.3
, lsp ==2.7.*
Expand All @@ -167,7 +167,7 @@ test-suite curry-language-server-test
, process >=1.6 && <2
, sorted-list ==0.2.*
, stm ==2.5.*
, text ==2.0.*
, text >=2.0 && <2.2
, text-rope ==0.2.*
, transformers >=0.5 && <0.7
, unliftio-core ==0.2.*
Expand Down
10 changes: 5 additions & 5 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ extra-source-files:

dependencies:
- base >= 4.16 && < 4.19
- aeson >= 2.0 && < 2.2
- aeson >= 2.2 && < 2.3
- async >= 2.2 && < 2.3
- containers >= 0.6 && < 0.7
- containers >= 0.6 && < 0.8
- data-default >= 0.7 && < 0.8
- extra >= 1.7 && < 1.8
- extra >= 1.7 && < 1.9
- either >= 5.0 && < 6
- mtl >= 2.2 && < 2.4
- transformers >= 0.5 && < 0.7
- exceptions >= 0.10 && < 0.11
- stm >= 2.5 && < 2.6
- text >= 2.0 && < 2.1
- text >= 2.0 && < 2.2
- text-rope >= 0.2 && < 0.3
- lens >= 5.1 && < 5.3
- co-log-core >= 0.3 && < 0.4
Expand All @@ -34,7 +34,7 @@ dependencies:
- sorted-list >= 0.2 && < 0.3
- lsp >= 2.7 && < 2.8
- unliftio-core >= 0.2 && < 0.3
- bytestring >= 0.11 && < 0.12
- bytestring >= 0.11 && < 0.13
- bytestring-trie >= 0.2 && < 0.3
- process >= 1.6 && < 2
- parsec >= 3.1 && < 4
Expand Down
6 changes: 2 additions & 4 deletions src/Curry/LanguageServer/Index/Convert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module Curry.LanguageServer.Index.Convert

-- Curry Compiler Libraries + Dependencies
import qualified Curry.Base.Ident as CI
import qualified Base.CurryKinds as CKS
import qualified Base.CurryTypes as CTS
import qualified Base.TopEnv as CTE
import qualified Base.Types as CT
import qualified Base.Kinds as CK
Expand Down Expand Up @@ -74,7 +72,7 @@ makeValueSymbol k q t = do
, printedType = Just $ ppToText t
-- We explicitly perform the Type -> TypeExpr conversion here since
-- the Pretty Type instance ignores the precedence.
, printedArgumentTypes = ppToTextPrec 2 . CTS.fromType CI.identSupply <$> CT.arrowArgs (CT.rawType t)
, printedArgumentTypes = ppToTextPrec 2 . CT.fromType CI.identSupply <$> CT.arrowArgs (CT.rawType t)
, printedResultType = Just $ ppToText $ CT.arrowBase (CT.rawType t)
, arrowArity = Just $ CT.arrowArity $ CT.rawType t
, location = loc
Expand All @@ -90,7 +88,7 @@ makeTypeSymbol k q k' = do
, printedType = Just $ ppToText k'
-- We explicitly perform the Kind conversion here since
-- the Pretty Kind instance ignores the precedence.
, printedArgumentTypes = ppToTextPrec 2 . CKS.fromKind <$> CK.kindArgs k'
, printedArgumentTypes = ppToTextPrec 2 . CK.fromKind <$> CK.kindArgs k'
, printedResultType = Just $ ppToText $ kindBase k'
, arrowArity = Just $ CK.kindArity k'
, location = loc
Expand Down
11 changes: 5 additions & 6 deletions src/Curry/LanguageServer/Utils/Convert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import qualified Curry.Base.Pretty as CPP
import qualified Curry.Base.Span as CSP
import qualified Curry.Base.SpanInfo as CSPI
import qualified Curry.Syntax as CS
import qualified Base.CurryTypes as CCT
import qualified Base.Types as CT
import qualified Text.PrettyPrint as PP

Expand Down Expand Up @@ -174,10 +173,10 @@ ppToText :: CPP.Pretty p => p -> T.Text
ppToText = T.pack . ppToString

ppTypeSchemeToText :: CI.ModuleIdent -> CT.TypeScheme -> T.Text
ppTypeSchemeToText mid = T.pack . PP.render . CCT.ppTypeScheme mid
ppTypeSchemeToText mid = T.pack . PP.render . CT.ppTypeScheme mid

ppPredTypeToText :: CI.ModuleIdent -> CT.PredType -> T.Text
ppPredTypeToText mid = T.pack . PP.render . CCT.ppPredType mid
ppPredTypeToText mid = T.pack . PP.render . CT.ppPredType mid

ppPatternToName :: CS.Pattern a -> T.Text
ppPatternToName pat = case pat of
Expand Down Expand Up @@ -234,7 +233,7 @@ instance HasDocumentSymbols (CS.Decl a) where
symKind = if patArity pat > 0 then J.SymbolKind_Function
else J.SymbolKind_Constant
childs = documentSymbols rhs
CS.ClassDecl _ _ _ ident _ decls -> [makeDocumentSymbol name symKind range $ Just childs]
CS.ClassDecl _ _ _ ident _ _ decls -> [makeDocumentSymbol name symKind range $ Just childs]
where name = ppToText ident
symKind = J.SymbolKind_Interface
childs = documentSymbols =<< decls
Expand All @@ -253,7 +252,7 @@ instance HasDocumentSymbols (CS.Decl a) where
CS.FunctionPattern _ _ _ ps -> length ps
_ -> 0
eqsArity :: [CS.Equation a] -> Int
eqsArity eqs = maybe 1 (\(CS.Equation _ lhs _) -> lhsArity lhs) $ listToMaybe eqs
eqsArity eqs = maybe 1 (\(CS.Equation _ _ lhs _) -> lhsArity lhs) $ listToMaybe eqs
range = currySpanInfo2Range $ CSPI.getSpanInfo decl

instance HasDocumentSymbols (CS.Var a) where
Expand All @@ -268,7 +267,7 @@ instance HasDocumentSymbols CS.ConstrDecl where
where range = currySpanInfo2Range $ CSPI.getSpanInfo decl

instance HasDocumentSymbols (CS.Equation a) where
documentSymbols (CS.Equation _ _ rhs) = documentSymbols rhs
documentSymbols (CS.Equation _ _ _ rhs) = documentSymbols rhs

instance HasDocumentSymbols (CS.Rhs a) where
documentSymbols rhs = case rhs of
Expand Down
4 changes: 2 additions & 2 deletions src/Curry/LanguageServer/Utils/Lookup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ instance CollectScope (LocalDecl a) a where
CS.FunctionDecl _ t i eqs -> bind i (Just t) >> collectScope eqs
CS.PatternDecl _ p rhs -> collectScope p >> collectScope rhs
CS.InstanceDecl _ _ _ _ _ ds -> collectScope $ TopDecl <$> ds
CS.ClassDecl _ _ _ _ _ ds -> collectScope $ TopDecl <$> ds
CS.ClassDecl _ _ _ _ _ _ ds -> collectScope $ TopDecl <$> ds
_ -> return ()

instance CollectScope (CS.Pattern a) a where
Expand All @@ -138,7 +138,7 @@ instance CollectScope (CS.Pattern a) a where


instance CollectScope (CS.Equation a) a where
collectScope eqn@(CS.Equation _ lhs rhs) = withScope $ collectScope lhs >> collectScope rhs >> updateEnvs eqn
collectScope eqn@(CS.Equation _ _ lhs rhs) = withScope $ collectScope lhs >> collectScope rhs >> updateEnvs eqn

instance CollectScope (CS.Lhs a) a where
collectScope lhs = (>> updateEnvs lhs) $ case lhs of
Expand Down
4 changes: 2 additions & 2 deletions src/Curry/LanguageServer/Utils/Sema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ instance HasTypedSpanInfos (CS.Decl a) a where
CS.ExternalDecl _ vs -> typedSpanInfos vs
CS.PatternDecl _ p rhs -> typedSpanInfos p ++ typedSpanInfos rhs
CS.FreeDecl _ vs -> typedSpanInfos vs
CS.ClassDecl _ _ _ _ _ ds -> typedSpanInfos ds
CS.ClassDecl _ _ _ _ _ _ ds -> typedSpanInfos ds
CS.InstanceDecl _ _ _ _ _ ds -> typedSpanInfos ds
_ -> []

instance HasTypedSpanInfos (CS.Equation a) a where
typedSpanInfos (CS.Equation _ lhs rhs) = typedSpanInfos lhs ++ typedSpanInfos rhs
typedSpanInfos (CS.Equation _ _ lhs rhs) = typedSpanInfos lhs ++ typedSpanInfos rhs

instance HasTypedSpanInfos (CS.Var a) a where
typedSpanInfos (CS.Var t i) = [TypedSpanInfo txt t $ CSPI.getSpanInfo i]
Expand Down
55 changes: 29 additions & 26 deletions src/Curry/LanguageServer/Utils/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ instance HasExpressions (CS.Module a) a where
instance HasExpressions (CS.Decl a) a where
expressions decl = case decl of
CS.FunctionDecl _ _ _ eqs -> expressions eqs
CS.ClassDecl _ _ _ _ _ ds -> expressions ds
CS.ClassDecl _ _ _ _ _ _ ds -> expressions ds
CS.InstanceDecl _ _ _ _ _ ds -> expressions ds
_ -> [] -- TODO

instance HasExpressions (CS.Equation a) a where
expressions (CS.Equation _ _ rhs) = expressions rhs
expressions (CS.Equation _ _ _ rhs) = expressions rhs

instance HasExpressions (CS.Rhs a) a where
expressions rhs = case rhs of
Expand Down Expand Up @@ -172,7 +172,7 @@ instance HasDeclarations (CS.Module a) a where
instance HasDeclarations (CS.Decl a) a where
declarations decl = decl : case decl of
-- TODO: Fetch declarations inside equations/expressions/...
CS.ClassDecl _ _ _ _ _ ds -> ds
CS.ClassDecl _ _ _ _ _ _ ds -> ds
CS.InstanceDecl _ _ _ _ _ ds -> ds
_ -> []

Expand Down Expand Up @@ -207,7 +207,7 @@ instance HasQualIdentifiers (CS.Decl a) where
CS.FunctionDecl _ _ _ es -> qualIdentifiers es
CS.PatternDecl _ p rhs -> qualIdentifiers p ++ qualIdentifiers rhs
CS.DefaultDecl _ es -> qualIdentifiers es
CS.ClassDecl _ _ _ _ _ ds -> qualIdentifiers ds
CS.ClassDecl _ _ _ _ _ _ ds -> qualIdentifiers ds
CS.InstanceDecl _ _ _ q _ ds -> q : qualIdentifiers ds
_ -> []

Expand All @@ -226,7 +226,7 @@ instance HasQualIdentifiers CS.NewConstrDecl where
CS.NewRecordDecl _ _ (_, t) -> qualIdentifiers t

instance HasQualIdentifiers (CS.Equation a) where
qualIdentifiers (CS.Equation _ lhs rhs) = qualIdentifiers lhs ++ qualIdentifiers rhs
qualIdentifiers (CS.Equation _ _ lhs rhs) = qualIdentifiers lhs ++ qualIdentifiers rhs

instance HasQualIdentifiers (CS.Lhs a) where
qualIdentifiers lhs = case lhs of
Expand Down Expand Up @@ -360,25 +360,28 @@ instance HasIdentifiers CS.Import where

instance HasIdentifiers (CS.Decl a) where
identifiers decl = case decl of
CS.InfixDecl _ _ _ is -> is
CS.DataDecl _ i is cdecls _ -> (i : is) ++ identifiers cdecls
CS.ExternalDataDecl _ i is -> i : is
CS.NewtypeDecl _ i is cdecl _ -> (i : is) ++ identifiers cdecl
CS.TypeDecl _ i is t -> (i : is) ++ identifiers t
CS.TypeSig _ is t -> is ++ identifiers t
CS.FunctionDecl _ _ i es -> i : identifiers es
CS.ExternalDecl _ vs -> identifiers vs
CS.PatternDecl _ p rhs -> identifiers p ++ identifiers rhs
CS.FreeDecl _ vs -> identifiers vs
CS.DefaultDecl _ ts -> identifiers ts
CS.ClassDecl _ _ c i1 i2 ds -> identifiers c ++ i1 : i2 : identifiers ds
CS.InstanceDecl _ _ c _ _ ds -> identifiers c ++ identifiers ds
CS.InfixDecl _ _ _ is -> is
CS.DataDecl _ i is cdecls _ -> (i : is) ++ identifiers cdecls
CS.ExternalDataDecl _ i is -> i : is
CS.NewtypeDecl _ i is cdecl _ -> (i : is) ++ identifiers cdecl
CS.TypeDecl _ i is t -> (i : is) ++ identifiers t
CS.TypeSig _ is t -> is ++ identifiers t
CS.FunctionDecl _ _ i es -> i : identifiers es
CS.ExternalDecl _ vs -> identifiers vs
CS.PatternDecl _ p rhs -> identifiers p ++ identifiers rhs
CS.FreeDecl _ vs -> identifiers vs
CS.DefaultDecl _ ts -> identifiers ts
CS.ClassDecl _ _ c i tvs fdeps ds -> identifiers c ++ i : tvs ++ identifiers fdeps ++ identifiers ds
CS.InstanceDecl _ _ c _ _ ds -> identifiers c ++ identifiers ds

instance HasIdentifiers CS.FunDep where
identifiers (CS.FunDep _ is1 is2) = is1 ++ is2

instance HasIdentifiers CS.Constraint where
identifiers (CS.Constraint _ _ t) = identifiers t

instance HasIdentifiers (CS.Equation a) where
identifiers (CS.Equation _ lhs rhs) = identifiers lhs ++ identifiers rhs
identifiers (CS.Equation _ _ lhs rhs) = identifiers lhs ++ identifiers rhs

instance HasIdentifiers (CS.Pattern a) where
identifiers pat = case pat of
Expand Down Expand Up @@ -505,10 +508,10 @@ class HasIdentifier e where

instance HasIdentifier (CS.Decl a) where
identifier decl = case decl of
CS.DataDecl _ ident _ _ _ -> Just ident
CS.ExternalDataDecl _ ident _ -> Just ident
CS.NewtypeDecl _ ident _ _ _ -> Just ident
CS.TypeDecl _ ident _ _ -> Just ident
CS.FunctionDecl _ _ ident _ -> Just ident
CS.ClassDecl _ _ _ ident _ _ -> Just ident
_ -> Nothing
CS.DataDecl _ ident _ _ _ -> Just ident
CS.ExternalDataDecl _ ident _ -> Just ident
CS.NewtypeDecl _ ident _ _ _ -> Just ident
CS.TypeDecl _ ident _ _ -> Just ident
CS.FunctionDecl _ _ ident _ -> Just ident
CS.ClassDecl _ _ _ ident _ _ _ -> Just ident
_ -> Nothing
20 changes: 18 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Resolver to choose a 'specific' stackage snapshot or a compiler version.
# A snapshot resolver dictates the compiler version and the set of packages
# to be used for project dependencies.
resolver: lts-22.30
resolver: lts-22.41

# User packages to be built.
packages:
Expand All @@ -16,11 +16,27 @@ packages:
# These entries can reference officially published versions as well as
# forks / in-progress versions pinned to a git hash. For example:
extra-deps:
- aeson-2.2.3.0
- binary-0.8.9.2
- bytestring-0.12.1.0
- character-ps-0.1
- containers-0.7
- directory-1.3.8.5
- extra-1.8
- filepath-1.4.300.2
- lsp-2.7.0.0
- lsp-types-2.3.0.0
- parsec-3.1.17.0
- process-1.6.20.0
- set-extra-1.4.2
- text-2.1.1
- time-1.9.3
- unix-2.8.5.1
- Win32-2.14.1.0
- git: https://git.ps.informatik.uni-kiel.de/curry/curry-frontend.git
commit: bd1750a68e011e56c176491a558885b5268173b5
commit: 67adff16d1166286db21e2fbddb88724674c95e9

allow-newer: true
Comment on lines 18 to +39
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we need quite a few extra-deps, since the Curry frontend decided to pull these in on top of the Stackage snapshot. allow-newer is needed due to conflicts, e.g. the newest version of lsp still requires extra 1.7, while the Curry frontend requires 1.8.

This list should get much shorter again once these packages make it to the next Stackage snapshot.


# Override default flag values for local packages and extra-deps
# flags: {}
Expand Down
Loading
Loading