{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
module Unison.LSP.Hover where
import Control.Lens hiding (List)
import Control.Monad.Reader
import Data.Text qualified as Text
import Language.LSP.Protocol.Lens
import Language.LSP.Protocol.Message qualified as Msg
import Language.LSP.Protocol.Types
import Unison.ABT qualified as ABT
import Unison.HashQualified qualified as HQ
import Unison.LSP.FileAnalysis (ppedForFile)
import Unison.LSP.Queries qualified as LSPQ
import Unison.LSP.Types
import Unison.LSP.VFS qualified as VFS
import Unison.LabeledDependency qualified as LD
import Unison.Parser.Ann (Ann)
import Unison.Pattern qualified as Pattern
import Unison.Prelude
import Unison.PrettyPrintEnv qualified as PPE
import Unison.PrettyPrintEnvDecl qualified as PPED
import Unison.Reference qualified as Reference
import Unison.Runtime.IOSource qualified as IOSource
import Unison.Symbol (Symbol)
import Unison.Syntax.DeclPrinter qualified as DeclPrinter
import Unison.Syntax.Name qualified as Name
import Unison.Syntax.TypePrinter qualified as TypePrinter
import Unison.Term qualified as Term
import Unison.Util.Pretty qualified as Pretty
import UnliftIO qualified
hoverHandler :: Msg.TRequestMessage 'Msg.Method_TextDocumentHover -> (Either Msg.ResponseError (Msg.MessageResult 'Msg.Method_TextDocumentHover) -> Lsp ()) -> Lsp ()
hoverHandler :: TRequestMessage 'Method_TextDocumentHover
-> (Either ResponseError (MessageResult 'Method_TextDocumentHover)
-> Lsp ())
-> Lsp ()
hoverHandler TRequestMessage 'Method_TextDocumentHover
m Either ResponseError (MessageResult 'Method_TextDocumentHover)
-> Lsp ()
respond = do
Either ResponseError (Hover |? Null) -> Lsp ()
Either ResponseError (MessageResult 'Method_TextDocumentHover)
-> Lsp ()
respond (Either ResponseError (Hover |? Null) -> Lsp ())
-> (Maybe Hover -> Either ResponseError (Hover |? Null))
-> Maybe Hover
-> Lsp ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Hover |? Null) -> Either ResponseError (Hover |? Null)
forall a b. b -> Either a b
Right ((Hover |? Null) -> Either ResponseError (Hover |? Null))
-> (Maybe Hover -> Hover |? Null)
-> Maybe Hover
-> Either ResponseError (Hover |? Null)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Hover |? Null)
-> (Hover -> Hover |? Null) -> Maybe Hover -> Hover |? Null
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Null -> Hover |? Null
forall a b. b -> a |? b
InR Null
Null) Hover -> Hover |? Null
forall a b. a -> a |? b
InL (Maybe Hover -> Lsp ()) -> Lsp (Maybe Hover) -> Lsp ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< MaybeT Lsp Hover -> Lsp (Maybe Hover)
forall (m :: * -> *) a. MaybeT m a -> m (Maybe a)
runMaybeT do
let pos :: Position
pos = (TRequestMessage 'Method_TextDocumentHover
m TRequestMessage 'Method_TextDocumentHover
-> Getting
Position (TRequestMessage 'Method_TextDocumentHover) Position
-> Position
forall s a. s -> Getting a s a -> a
^. (HoverParams -> Const Position HoverParams)
-> TRequestMessage 'Method_TextDocumentHover
-> Const Position (TRequestMessage 'Method_TextDocumentHover)
forall s a. HasParams s a => Lens' s a
Lens' (TRequestMessage 'Method_TextDocumentHover) HoverParams
params ((HoverParams -> Const Position HoverParams)
-> TRequestMessage 'Method_TextDocumentHover
-> Const Position (TRequestMessage 'Method_TextDocumentHover))
-> ((Position -> Const Position Position)
-> HoverParams -> Const Position HoverParams)
-> Getting
Position (TRequestMessage 'Method_TextDocumentHover) Position
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Position -> Const Position Position)
-> HoverParams -> Const Position HoverParams
forall s a. HasPosition s a => Lens' s a
Lens' HoverParams Position
position)
Text
hoverTxt <- Uri -> Position -> MaybeT Lsp Text
hoverInfo (TRequestMessage 'Method_TextDocumentHover
m TRequestMessage 'Method_TextDocumentHover
-> Getting Uri (TRequestMessage 'Method_TextDocumentHover) Uri
-> Uri
forall s a. s -> Getting a s a -> a
^. (HoverParams -> Const Uri HoverParams)
-> TRequestMessage 'Method_TextDocumentHover
-> Const Uri (TRequestMessage 'Method_TextDocumentHover)
forall s a. HasParams s a => Lens' s a
Lens' (TRequestMessage 'Method_TextDocumentHover) HoverParams
params ((HoverParams -> Const Uri HoverParams)
-> TRequestMessage 'Method_TextDocumentHover
-> Const Uri (TRequestMessage 'Method_TextDocumentHover))
-> ((Uri -> Const Uri Uri) -> HoverParams -> Const Uri HoverParams)
-> Getting Uri (TRequestMessage 'Method_TextDocumentHover) Uri
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentIdentifier -> Const Uri TextDocumentIdentifier)
-> HoverParams -> Const Uri HoverParams
forall s a. HasTextDocument s a => Lens' s a
Lens' HoverParams TextDocumentIdentifier
textDocument ((TextDocumentIdentifier -> Const Uri TextDocumentIdentifier)
-> HoverParams -> Const Uri HoverParams)
-> ((Uri -> Const Uri Uri)
-> TextDocumentIdentifier -> Const Uri TextDocumentIdentifier)
-> (Uri -> Const Uri Uri)
-> HoverParams
-> Const Uri HoverParams
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Uri -> Const Uri Uri)
-> TextDocumentIdentifier -> Const Uri TextDocumentIdentifier
forall s a. HasUri s a => Lens' s a
Lens' TextDocumentIdentifier Uri
uri) Position
pos
pure $
Hover
{ $sel:_contents:Hover :: MarkupContent |? (MarkedString |? [MarkedString])
_contents = MarkupContent -> MarkupContent |? (MarkedString |? [MarkedString])
forall a b. a -> a |? b
InL (MarkupKind -> Text -> MarkupContent
MarkupContent MarkupKind
MarkupKind_Markdown Text
hoverTxt),
$sel:_range:Hover :: Maybe Range
_range = Maybe Range
forall a. Maybe a
Nothing
}
hoverInfo :: Uri -> Position -> MaybeT Lsp Text
hoverInfo :: Uri -> Position -> MaybeT Lsp Text
hoverInfo Uri
uri Position
pos =
(MaybeT Lsp Text
hoverInfoForRef MaybeT Lsp Text -> MaybeT Lsp Text -> MaybeT Lsp Text
forall a. MaybeT Lsp a -> MaybeT Lsp a -> MaybeT Lsp a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> MaybeT Lsp Text
hoverInfoForLiteral)
where
markdownify :: Text -> Text
markdownify :: Text -> Text
markdownify Text
rendered = [Text] -> Text
Text.unlines [Text
"``` unison", Text
rendered, Text
"```"]
prettyWidth :: Pretty.Width
prettyWidth :: Width
prettyWidth = Width
40
hoverInfoForRef :: MaybeT Lsp Text
hoverInfoForRef :: MaybeT Lsp Text
hoverInfoForRef = do
Text
symAtCursor <- Uri -> Position -> MaybeT Lsp Text
VFS.identifierAtPosition Uri
uri Position
pos
LabeledDependency
ref <- Uri -> Position -> MaybeT Lsp LabeledDependency
LSPQ.refAtPosition Uri
uri Position
pos
PrettyPrintEnvDecl
pped <- Lsp PrettyPrintEnvDecl -> MaybeT Lsp PrettyPrintEnvDecl
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Lsp PrettyPrintEnvDecl -> MaybeT Lsp PrettyPrintEnvDecl)
-> Lsp PrettyPrintEnvDecl -> MaybeT Lsp PrettyPrintEnvDecl
forall a b. (a -> b) -> a -> b
$ Uri -> Lsp PrettyPrintEnvDecl
ppedForFile Uri
uri
let unsuffixifiedPPE :: PrettyPrintEnv
unsuffixifiedPPE = PrettyPrintEnvDecl -> PrettyPrintEnv
PPED.unsuffixifiedPPE PrettyPrintEnvDecl
pped
let fqn :: HashQualified Name
fqn = case LabeledDependency
ref of
LD.TypeReference Reference
ref -> PrettyPrintEnv -> Reference -> HashQualified Name
PPE.typeName PrettyPrintEnv
unsuffixifiedPPE Reference
ref
LD.TermReferent Referent
ref -> PrettyPrintEnv -> Referent -> HashQualified Name
PPE.termName PrettyPrintEnv
unsuffixifiedPPE Referent
ref
Async (TypecheckedUnisonFile Symbol Ann)
builtinsAsync <- IO (Async (TypecheckedUnisonFile Symbol Ann))
-> MaybeT Lsp (Async (TypecheckedUnisonFile Symbol Ann))
forall a. IO a -> MaybeT Lsp a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Async (TypecheckedUnisonFile Symbol Ann))
-> MaybeT Lsp (Async (TypecheckedUnisonFile Symbol Ann)))
-> (IO (TypecheckedUnisonFile Symbol Ann)
-> IO (Async (TypecheckedUnisonFile Symbol Ann)))
-> IO (TypecheckedUnisonFile Symbol Ann)
-> MaybeT Lsp (Async (TypecheckedUnisonFile Symbol Ann))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (TypecheckedUnisonFile Symbol Ann)
-> IO (Async (TypecheckedUnisonFile Symbol Ann))
forall (m :: * -> *) a. MonadUnliftIO m => m a -> m (Async a)
UnliftIO.async (IO (TypecheckedUnisonFile Symbol Ann)
-> MaybeT Lsp (Async (TypecheckedUnisonFile Symbol Ann)))
-> IO (TypecheckedUnisonFile Symbol Ann)
-> MaybeT Lsp (Async (TypecheckedUnisonFile Symbol Ann))
forall a b. (a -> b) -> a -> b
$ TypecheckedUnisonFile Symbol Ann
-> IO (TypecheckedUnisonFile Symbol Ann)
forall (m :: * -> *) a. MonadIO m => a -> m a
UnliftIO.evaluate TypecheckedUnisonFile Symbol Ann
IOSource.typecheckedFile
MaybeT Lsp Bool
checkBuiltinsReady <- IO (MaybeT Lsp Bool) -> MaybeT Lsp (MaybeT Lsp Bool)
forall a. IO a -> MaybeT Lsp a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO do
MaybeT Lsp Bool -> IO (MaybeT Lsp Bool)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
( Async (TypecheckedUnisonFile Symbol Ann)
-> MaybeT
Lsp
(Maybe (Either SomeException (TypecheckedUnisonFile Symbol Ann)))
forall (m :: * -> *) a.
MonadIO m =>
Async a -> m (Maybe (Either SomeException a))
UnliftIO.poll Async (TypecheckedUnisonFile Symbol Ann)
builtinsAsync
MaybeT
Lsp
(Maybe (Either SomeException (TypecheckedUnisonFile Symbol Ann)))
-> (Maybe (Either SomeException (TypecheckedUnisonFile Symbol Ann))
-> Bool)
-> MaybeT Lsp Bool
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> ( \case
Maybe (Either SomeException (TypecheckedUnisonFile Symbol Ann))
Nothing -> Bool
False
Just (Left {}) -> Bool
False
Just (Right {}) -> Bool
True
)
)
[Text]
renderedDocs <-
Lsp (Maybe [Text]) -> MaybeT Lsp (Maybe [Text])
forall (m :: * -> *) a. Monad m => m a -> MaybeT m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (Int -> Lsp [Text] -> Lsp (Maybe [Text])
forall (m :: * -> *) a.
MonadUnliftIO m =>
Int -> m a -> m (Maybe a)
UnliftIO.timeout Int
2_000_000 (Uri -> HashQualified Name -> Lsp [Text]
LSPQ.markdownDocsForFQN Uri
uri HashQualified Name
fqn))
MaybeT Lsp (Maybe [Text])
-> (Maybe [Text] -> MaybeT Lsp [Text]) -> MaybeT Lsp [Text]
forall a b. MaybeT Lsp a -> (a -> MaybeT Lsp b) -> MaybeT Lsp b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ( \case
Maybe [Text]
Nothing ->
MaybeT Lsp Bool
checkBuiltinsReady MaybeT Lsp Bool -> (Bool -> MaybeT Lsp [Text]) -> MaybeT Lsp [Text]
forall a b. MaybeT Lsp a -> (a -> MaybeT Lsp b) -> MaybeT Lsp b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Bool
False -> [Text] -> MaybeT Lsp [Text]
forall a. a -> MaybeT Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Text
"\n---\n🔜 Doc renderer is initializing, try again in a few seconds."]
Bool
True -> [Text] -> MaybeT Lsp [Text]
forall a. a -> MaybeT Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [Text
"\n---\n⏳ Timeout evaluating docs"]
Just [] -> [Text] -> MaybeT Lsp [Text]
forall a. a -> MaybeT Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure []
Just xs :: [Text]
xs@(Text
_ : [Text]
_) -> [Text] -> MaybeT Lsp [Text]
forall a. a -> MaybeT Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text
"\n---\n" Text -> [Text] -> [Text]
forall a. a -> [a] -> [a]
: [Text]
xs)
)
Text
typeSig <-
case LabeledDependency
ref of
LD.TypeReference (Reference.Builtin {}) -> do
Text -> MaybeT Lsp Text
forall a. a -> MaybeT Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text
symAtCursor Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" : <builtin>")
LD.TypeReference ref :: Reference
ref@(Reference.DerivedId Id' Hash
refId) -> do
Name
nameAtCursor <- Lsp (Maybe Name) -> MaybeT Lsp Name
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (Lsp (Maybe Name) -> MaybeT Lsp Name)
-> (Maybe Name -> Lsp (Maybe Name))
-> Maybe Name
-> MaybeT Lsp Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Name -> Lsp (Maybe Name)
forall a. a -> Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe Name -> MaybeT Lsp Name) -> Maybe Name -> MaybeT Lsp Name
forall a b. (a -> b) -> a -> b
$ Text -> Maybe Name
Name.parseText Text
symAtCursor
Decl Symbol Ann
decl <- Uri -> Id' Hash -> MaybeT Lsp (Decl Symbol Ann)
LSPQ.getTypeDeclaration Uri
uri Id' Hash
refId
let typ :: Text
typ = String -> Text
Text.pack (String -> Text)
-> (Pretty SyntaxText -> String) -> Pretty SyntaxText -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Width -> Pretty ColorText -> String
Pretty.toPlain Width
prettyWidth (Pretty ColorText -> String)
-> (Pretty SyntaxText -> Pretty ColorText)
-> Pretty SyntaxText
-> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pretty SyntaxText -> Pretty ColorText
forall r. Pretty (SyntaxText' r) -> Pretty ColorText
Pretty.syntaxToColor (Pretty SyntaxText -> Text) -> Pretty SyntaxText -> Text
forall a b. (a -> b) -> a -> b
$ PrettyPrintEnvDecl
-> Reference
-> HashQualified Name
-> Decl Symbol Ann
-> Pretty SyntaxText
forall v a.
Var v =>
PrettyPrintEnvDecl
-> Reference -> HashQualified Name -> Decl v a -> Pretty SyntaxText
DeclPrinter.prettyDecl PrettyPrintEnvDecl
pped Reference
ref (Name -> HashQualified Name
forall n. n -> HashQualified n
HQ.NameOnly Name
nameAtCursor) Decl Symbol Ann
decl
Text -> MaybeT Lsp Text
forall a. a -> MaybeT Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Text
typ
LD.TermReferent Referent
ref -> do
Type Symbol Ann
typ <- Uri -> Referent -> MaybeT Lsp (Type Symbol Ann)
LSPQ.getTypeOfReferent Uri
uri Referent
ref
let renderedType :: Text
renderedType = String -> Text
Text.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$ Maybe Width -> PrettyPrintEnv -> Type Symbol Ann -> String
forall v a.
Var v =>
Maybe Width -> PrettyPrintEnv -> Type v a -> String
TypePrinter.prettyStr (Width -> Maybe Width
forall a. a -> Maybe a
Just Width
prettyWidth) (PrettyPrintEnvDecl -> PrettyPrintEnv
PPED.suffixifiedPPE PrettyPrintEnvDecl
pped) Type Symbol Ann
typ
Text -> MaybeT Lsp Text
forall a. a -> MaybeT Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text
symAtCursor Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" : " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
renderedType)
Text -> MaybeT Lsp Text
forall a. a -> MaybeT Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> MaybeT Lsp Text)
-> ([Text] -> Text) -> [Text] -> MaybeT Lsp Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Text] -> Text
Text.unlines ([Text] -> MaybeT Lsp Text) -> [Text] -> MaybeT Lsp Text
forall a b. (a -> b) -> a -> b
$ [Text -> Text
markdownify Text
typeSig] [Text] -> [Text] -> [Text]
forall a. Semigroup a => a -> a -> a
<> [Text]
renderedDocs
hoverInfoForLiteral :: MaybeT Lsp Text
hoverInfoForLiteral :: MaybeT Lsp Text
hoverInfoForLiteral =
Text -> Text
markdownify (Text -> Text) -> MaybeT Lsp Text -> MaybeT Lsp Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
Uri -> Position -> MaybeT Lsp (SourceNode Ann)
LSPQ.nodeAtPosition Uri
uri Position
pos MaybeT Lsp (SourceNode Ann)
-> (SourceNode Ann -> MaybeT Lsp Text) -> MaybeT Lsp Text
forall a b. MaybeT Lsp a -> (a -> MaybeT Lsp b) -> MaybeT Lsp b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
LSPQ.TermNode Term Symbol Ann
term -> do
Text
typ <- Maybe Text -> MaybeT Lsp Text
forall a. Maybe a -> MaybeT Lsp a
hoistMaybe (Maybe Text -> MaybeT Lsp Text) -> Maybe Text -> MaybeT Lsp Text
forall a b. (a -> b) -> a -> b
$ Term Symbol Ann -> Maybe Text
builtinTypeForTermLiterals Term Symbol Ann
term
pure (Text
": " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
typ)
LSPQ.TypeNode {} -> MaybeT Lsp Text
forall a. MaybeT Lsp a
forall (f :: * -> *) a. Alternative f => f a
empty
LSPQ.PatternNode Pattern Ann
pat -> do
Text
typ <- Maybe Text -> MaybeT Lsp Text
forall a. Maybe a -> MaybeT Lsp a
hoistMaybe (Maybe Text -> MaybeT Lsp Text) -> Maybe Text -> MaybeT Lsp Text
forall a b. (a -> b) -> a -> b
$ Pattern Ann -> Maybe Text
builtinTypeForPatternLiterals Pattern Ann
pat
pure (Text
": " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
typ)
hoistMaybe :: Maybe a -> MaybeT Lsp a
hoistMaybe :: forall a. Maybe a -> MaybeT Lsp a
hoistMaybe = Lsp (Maybe a) -> MaybeT Lsp a
forall (m :: * -> *) a. m (Maybe a) -> MaybeT m a
MaybeT (Lsp (Maybe a) -> MaybeT Lsp a)
-> (Maybe a -> Lsp (Maybe a)) -> Maybe a -> MaybeT Lsp a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe a -> Lsp (Maybe a)
forall a. a -> Lsp a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
builtinTypeForTermLiterals :: Term.Term Symbol Ann -> Maybe Text
builtinTypeForTermLiterals :: Term Symbol Ann -> Maybe Text
builtinTypeForTermLiterals Term Symbol Ann
term =
case Term Symbol Ann -> ABT (F Symbol Ann Ann) Symbol (Term Symbol Ann)
forall (f :: * -> *) v a. Term f v a -> ABT f v (Term f v a)
ABT.out Term Symbol Ann
term of
ABT.Tm F Symbol Ann Ann (Term Symbol Ann)
f -> case F Symbol Ann Ann (Term Symbol Ann)
f of
Term.Int {} -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Int"
Term.Nat {} -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Nat"
Term.Float {} -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Float"
Term.Boolean {} -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Boolean"
Term.Text {} -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Text"
Term.Char {} -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Char"
Term.Blank {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Ref {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Constructor {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Request {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Handle {} -> Maybe Text
forall a. Maybe a
Nothing
Term.App {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Ann {} -> Maybe Text
forall a. Maybe a
Nothing
Term.List {} -> Maybe Text
forall a. Maybe a
Nothing
Term.If {} -> Maybe Text
forall a. Maybe a
Nothing
Term.And {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Or {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Lam {} -> Maybe Text
forall a. Maybe a
Nothing
Term.LetRec {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Let {} -> Maybe Text
forall a. Maybe a
Nothing
Term.Match {} -> Maybe Text
forall a. Maybe a
Nothing
Term.TermLink {} -> Maybe Text
forall a. Maybe a
Nothing
Term.TypeLink {} -> Maybe Text
forall a. Maybe a
Nothing
ABT.Var {} -> Maybe Text
forall a. Maybe a
Nothing
ABT.Cycle {} -> Maybe Text
forall a. Maybe a
Nothing
ABT.Abs {} -> Maybe Text
forall a. Maybe a
Nothing
builtinTypeForPatternLiterals :: Pattern.Pattern Ann -> Maybe Text
builtinTypeForPatternLiterals :: Pattern Ann -> Maybe Text
builtinTypeForPatternLiterals = \case
Pattern.Unbound Ann
_ -> Maybe Text
forall a. Maybe a
Nothing
Pattern.Var Ann
_ -> Maybe Text
forall a. Maybe a
Nothing
Pattern.Boolean Ann
_ Bool
_ -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Boolean"
Pattern.Int Ann
_ Int64
_ -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Int"
Pattern.Nat Ann
_ Word64
_ -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Nat"
Pattern.Float Ann
_ Double
_ -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Float"
Pattern.Text Ann
_ Text
_ -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Text"
Pattern.Char Ann
_ Char
_ -> Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Char"
Pattern.Constructor Ann
_ ConstructorReference
_ [Pattern Ann]
_ -> Maybe Text
forall a. Maybe a
Nothing
Pattern.As Ann
_ Pattern Ann
_ -> Maybe Text
forall a. Maybe a
Nothing
Pattern.EffectPure Ann
_ Pattern Ann
_ -> Maybe Text
forall a. Maybe a
Nothing
Pattern.EffectBind Ann
_ ConstructorReference
_ [Pattern Ann]
_ Pattern Ann
_ -> Maybe Text
forall a. Maybe a
Nothing
Pattern.SequenceLiteral Ann
_ [Pattern Ann]
_ -> Maybe Text
forall a. Maybe a
Nothing
Pattern.SequenceOp Ann
_ Pattern Ann
_ SeqOp
_ Pattern Ann
_ -> Maybe Text
forall a. Maybe a
Nothing