@@ -12,42 +12,93 @@
12-- Type definitions for psc-ide
12-- Type definitions for psc-ide
13-----------------------------------------------------------------------------
13-----------------------------------------------------------------------------
15−{-# LANGUAGE OverloadedStrings #-}
16{-# LANGUAGE DeriveFoldable #-}
15{-# LANGUAGE DeriveFoldable #-}
16+{-# LANGUAGE OverloadedStrings #-}
17+{-# LANGUAGE TemplateHaskell #-}
18module Language.PureScript.Ide.Types where
19module Language.PureScript.Ide.Types where
20import Protolude
21import Protolude
22import Control.Concurrent.STM
23import Control.Concurrent.STM
24+import Control.Lens.TH
23import Data.Aeson
25import Data.Aeson
24−import qualified Data.Map.Lazy as M
26+import qualified Data.Map.Lazy as M
25−import qualified Language.PureScript.Errors.JSON as P
27+import qualified Language.PureScript as P
26−import qualified Language.PureScript as P
28+import qualified Language.PureScript.Errors.JSON as P
27import Language.PureScript.Ide.Conversions
29import Language.PureScript.Ide.Conversions
29type ModuleIdent = Text
31type ModuleIdent = Text
31data IdeDeclaration
33data IdeDeclaration
32− = IdeValue P.Ident P.Type
34+ = IdeDeclValue IdeValue
33− | IdeType (P.ProperName 'P.TypeName) P.Kind
35+ | IdeDeclType IdeType
34− | IdeTypeSynonym (P.ProperName 'P.TypeName) P.Type
36+ | IdeDeclTypeSynonym IdeSynonym
35− | IdeDataConstructor (P.ProperName 'P.ConstructorName) (P.ProperName 'P.TypeName) P.Type
37+ | IdeDeclDataConstructor IdeDataConstructor
36− | IdeTypeClass (P.ProperName 'P.ClassName)
38+ | IdeDeclTypeClass (P.ProperName 'P.ClassName)
37− | IdeValueOperator (P.OpName 'P.ValueOpName) (P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName))) P.Precedence P.Associativity (Maybe P.Type)
39+ | IdeDeclValueOperator IdeValueOperator
38− | IdeTypeOperator (P.OpName 'P.TypeOpName) (P.Qualified (P.ProperName 'P.TypeName)) P.Precedence P.Associativity (Maybe P.Kind)
40+ | IdeDeclTypeOperator IdeTypeOperator
39 deriving (Show, Eq, Ord)
41 deriving (Show, Eq, Ord)
43+data IdeValue = IdeValue
44+ { _ideValueIdent :: P.Ident
45+ , _ideValueType :: P.Type
46+ } deriving (Show, Eq, Ord)
48+data IdeType = IdeType
49+ { _ideTypeName :: P.ProperName 'P.TypeName
50+ , _ideTypeKind :: P.Kind
51+ } deriving (Show, Eq, Ord)
53+data IdeSynonym = IdeSynonym
54+ { _ideSynonymName :: P.ProperName 'P.TypeName
55+ , _ideSynonymType :: P.Type
56+ } deriving (Show, Eq, Ord)
58+data IdeDataConstructor = IdeDataConstructor
59+ { _ideDtorName :: P.ProperName 'P.ConstructorName
60+ , _ideDtorTypeName :: P.ProperName 'P.TypeName
61+ , _ideDtorType :: P.Type
62+ } deriving (Show, Eq, Ord)
64+data IdeValueOperator = IdeValueOperator
65+ { _ideValueOpName :: P.OpName 'P.ValueOpName
66+ , _ideValueOpAlias :: P.Qualified (Either P.Ident (P.ProperName 'P.ConstructorName))
67+ , _ideValueOpPrecedence :: P.Precedence
68+ , _ideValueOpAssociativity :: P.Associativity
69+ , _ideValueOpType :: Maybe P.Type
70+ } deriving (Show, Eq, Ord)
72+data IdeTypeOperator = IdeTypeOperator
73+ { _ideTypeOpName :: P.OpName 'P.TypeOpName
74+ , _ideTypeOpAlias :: P.Qualified (P.ProperName 'P.TypeName)
75+ , _ideTypeOpPrecedence :: P.Precedence
76+ , _ideTypeOpAssociativity :: P.Associativity
77+ , _ideTypeOpKind :: Maybe P.Kind
78+ } deriving (Show, Eq, Ord)
80+makePrisms ''IdeDeclaration
83+makeLenses ''IdeSynonym
84+makeLenses ''IdeDataConstructor
85+makeLenses ''IdeValueOperator
86+makeLenses ''IdeTypeOperator
41−data IdeDeclarationAnn = IdeDeclarationAnn Annotation IdeDeclaration
88+data IdeDeclarationAnn = IdeDeclarationAnn
89+ { _idaAnnotation :: Annotation
90+ , _idaDeclaration :: IdeDeclaration
42− deriving (Show, Eq, Ord)
91+ } deriving (Show, Eq, Ord)
44data Annotation
93data Annotation
45 = Annotation
94 = Annotation
46− { annLocation :: Maybe P.SourceSpan
95+ { annLocation :: Maybe P.SourceSpan
47− , annExportedFrom :: Maybe P.ModuleName
96+ , annExportedFrom :: Maybe P.ModuleName
48 , annTypeAnnotation :: Maybe P.Type
97 , annTypeAnnotation :: Maybe P.Type
49 } deriving (Show, Eq, Ord)
98 } deriving (Show, Eq, Ord)
100+makeLenses ''IdeDeclarationAnn
51emptyAnn :: Annotation
102emptyAnn :: Annotation
52emptyAnn = Annotation Nothing Nothing Nothing
103emptyAnn = Annotation Nothing Nothing Nothing
@@ -103,7 +154,7 @@ data Stage2 = Stage2
105data Stage3 = Stage3
156data Stage3 = Stage3
106− { s3Declarations :: M.Map P.ModuleName [IdeDeclarationAnn]
157+ { s3Declarations :: M.Map P.ModuleName [IdeDeclarationAnn]
107 , s3CachedRebuild :: Maybe (P.ModuleName, P.ExternsFile)
158 , s3CachedRebuild :: Maybe (P.ModuleName, P.ExternsFile)
@@ -112,11 +163,11 @@ newtype Match a = Match (P.ModuleName, a)
113-- | A completion as it gets sent to the editors
164-- | A completion as it gets sent to the editors
114data Completion = Completion
165data Completion = Completion
115− { complModule :: Text
166+ { complModule :: Text
116− , complIdentifier :: Text
167+ , complIdentifier :: Text
117− , complType :: Text
168+ , complType :: Text
118− , complExpandedType :: Text
169+ , complExpandedType :: Text
119− , complLocation :: Maybe P.SourceSpan
170+ , complLocation :: Maybe P.SourceSpan
120 , complDocumentation :: Maybe Text
171 , complDocumentation :: Maybe Text
121 } deriving (Show, Eq)
172 } deriving (Show, Eq)