@@ -42,14 +42,14 @@ import Language.LSP.Protocol.Types (NormalizedUri, Position (..), Range (..),
4242import qualified Language.LSP.Protocol.Types as LSPTypes
4343import Language.LSP.Server
4444
45- import Telomare (LocTag (.. ), PatternF (.. ), ResolverError (.. ),
46- SourcePosition (.. ), SourceSpan (.. ),
45+ import Telomare (AUPT , AnnotatedUPT (.. ), BasicExprF (.. ), HighTermF (.. ),
46+ LamTermF (.. ), LocTag (.. ), PatternA , PatternF (.. ),
47+ ResolverError (.. ), SourcePosition (.. ), SourceSpan (.. ),
4748 UnprocessedParsedTermF (.. ), letBindingName , letBindingValue ,
4849 locStartLineColumn , locatedNameLoc , locatedNameText ,
4950 renderResolverError )
5051import Telomare.Eval (eval2IExpr )
51- import Telomare.Parser (AUPT , AnnotatedUPT (.. ), PatternA , parseModule ,
52- parseModuleDetailed )
52+ import Telomare.Parser (parseModule , parseModuleDetailed )
5353import Telomare.Resolver (main2Term3 )
5454import Text.Megaparsec.Error (ParseErrorBundle (.. ), errorBundlePretty ,
5555 errorOffset )
@@ -406,27 +406,27 @@ unresolvedTerm :: Set.Set String -> AUPT -> [(String, Range)]
406406unresolvedTerm globals = go Set. empty
407407 where
408408 go bound (loc :< term) = case term of
409- VarUPF name
409+ UnprocessedParsedTermL ( VarF name)
410410 | name `Set.member` bound || name `Set.member` globals -> []
411411 | otherwise -> [(name, locTagToRange loc)]
412412 LetUPF bindings body ->
413413 let localNames = Set. fromList $ letBindingName <$> bindings
414414 bound' = localNames <> bound
415415 in concatMap (go bound' . letBindingValue) bindings <> go bound' body
416- LamUPF name body -> go (Set. insert (locatedNameText name) bound) body
416+ UnprocessedParsedTermL ( LamF name body) -> go (Set. insert (locatedNameText name) bound) body
417417 UDTUPF names body -> go (Set. union (Set. fromList names) bound) body
418418 CaseUPF scrutinee cases ->
419419 go bound scrutinee <> concatMap (caseRefs bound) cases
420- ITEUPF i t e -> concatMap (go bound) [i, t, e]
420+ UnprocessedParsedTermH ( ITEF i t e) -> concatMap (go bound) [i, t, e]
421421 ListUPF items -> concatMap (go bound) items
422- PairUPF a b -> concatMap (go bound) [a, b]
423- AppUPF f x -> concatMap (go bound) [f, x]
424- LeftUPF x -> go bound x
425- RightUPF x -> go bound x
426- TraceUPF x -> go bound x
427- CheckUPF checkExpr body -> go bound checkExpr <> go bound body
428- HashUPF x -> go bound x
429- UnsizedRecursionUPF t r b -> concatMap (go bound) [t, r, b]
422+ UnprocessedParsedTermB ( PairSF a b) -> concatMap (go bound) [a, b]
423+ UnprocessedParsedTermL ( AppF f x) -> concatMap (go bound) [f, x]
424+ UnprocessedParsedTermH ( HLeftF x) -> go bound x
425+ UnprocessedParsedTermH ( HRightF x) -> go bound x
426+ UnprocessedParsedTermH ( HTraceF x) -> go bound x
427+ UnprocessedParsedTermH ( CheckF checkExpr body) -> go bound checkExpr <> go bound body
428+ UnprocessedParsedTermH ( HashF x) -> go bound x
429+ UnprocessedParsedTermH ( RecursionF t r b) -> concatMap (go bound) [t, r, b]
430430 _ -> []
431431
432432 caseRefs bound (pat, body) =
@@ -707,23 +707,23 @@ findIdentifierInLhs name lineText = go 0 lhs
707707termReferences :: [String ] -> AUPT -> [(String , Range )]
708708termReferences bound (loc :< term) =
709709 let children = case term of
710- VarUPF name
710+ UnprocessedParsedTermL ( VarF name)
711711 | name `elem` bound -> []
712712 | otherwise -> [(name, locTagToRange loc)]
713- ITEUPF i t e -> termReferences bound i <> termReferences bound t <> termReferences bound e
713+ UnprocessedParsedTermH ( ITEF i t e) -> termReferences bound i <> termReferences bound t <> termReferences bound e
714714 LetUPF bindings body ->
715715 let localNames = letBindingName <$> bindings
716716 bound' = localNames <> bound
717717 in concatMap (termReferences bound' . letBindingValue) bindings <> termReferences bound' body
718718 ListUPF items -> concatMap (termReferences bound) items
719- PairUPF a b -> termReferences bound a <> termReferences bound b
720- AppUPF f x -> termReferences bound f <> termReferences bound x
721- LamUPF var body -> termReferences (locatedNameText var : bound) body
722- LeftUPF x -> termReferences bound x
723- RightUPF x -> termReferences bound x
724- TraceUPF x -> termReferences bound x
725- CheckUPF checkExpr body -> termReferences bound checkExpr <> termReferences bound body
726- HashUPF x -> termReferences bound x
719+ UnprocessedParsedTermB ( PairSF a b) -> termReferences bound a <> termReferences bound b
720+ UnprocessedParsedTermL ( AppF f x) -> termReferences bound f <> termReferences bound x
721+ UnprocessedParsedTermL ( LamF var body) -> termReferences (locatedNameText var : bound) body
722+ UnprocessedParsedTermH ( HLeftF x) -> termReferences bound x
723+ UnprocessedParsedTermH ( HRightF x) -> termReferences bound x
724+ UnprocessedParsedTermH ( HTraceF x) -> termReferences bound x
725+ UnprocessedParsedTermH ( CheckF checkExpr body) -> termReferences bound checkExpr <> termReferences bound body
726+ UnprocessedParsedTermH ( HashF x) -> termReferences bound x
727727 UDTUPF names body -> termReferences (names <> bound) body
728728 CaseUPF scrutinee cases -> termReferences bound scrutinee <> concatMap caseReferences cases
729729 _ -> []
@@ -744,7 +744,7 @@ localTermDefinitionAt :: LSPTypes.Uri
744744 -> AUPT
745745 -> Maybe LSPTypes. Location
746746localTermDefinitionAt uri position env (loc :< term) = case term of
747- VarUPF name
747+ UnprocessedParsedTermL ( VarF name)
748748 | positionInRange position (locTagToRange loc) -> join $ Map. lookup name env
749749 | otherwise -> Nothing
750750 LetUPF bindings body ->
@@ -764,22 +764,22 @@ localTermDefinitionAt uri position env (loc :< term) = case term of
764764 , location <- foldMap pure $ localTermDefinitionAt uri position env' (letBindingValue binding)
765765 ]
766766 in bindingDefinition <|> bindingRefs <|> localTermDefinitionAt uri position env' body
767- ITEUPF i t e -> firstJust [i, t, e]
767+ UnprocessedParsedTermH ( ITEF i t e) -> firstJust [i, t, e]
768768 ListUPF items -> firstJust items
769- PairUPF a b -> firstJust [a, b]
770- AppUPF f x -> firstJust [f, x]
771- LamUPF name body ->
769+ UnprocessedParsedTermB ( PairSF a b) -> firstJust [a, b]
770+ UnprocessedParsedTermL ( AppF f x) -> firstJust [f, x]
771+ UnprocessedParsedTermL ( LamF name body) ->
772772 let nameLoc = locatedNameLoc name
773773 location = LSPTypes. Location uri (locTagToRange nameLoc)
774774 env' = Map. insert (locatedNameText name) (Just location) env
775775 in if positionInRange position (locTagToRange nameLoc)
776776 then Just location
777777 else localTermDefinitionAt uri position env' body
778- LeftUPF x -> localTermDefinitionAt uri position env x
779- RightUPF x -> localTermDefinitionAt uri position env x
780- TraceUPF x -> localTermDefinitionAt uri position env x
781- CheckUPF checkExpr body -> firstJust [checkExpr, body]
782- HashUPF x -> localTermDefinitionAt uri position env x
778+ UnprocessedParsedTermH ( HLeftF x) -> localTermDefinitionAt uri position env x
779+ UnprocessedParsedTermH ( HRightF x) -> localTermDefinitionAt uri position env x
780+ UnprocessedParsedTermH ( HTraceF x) -> localTermDefinitionAt uri position env x
781+ UnprocessedParsedTermH ( CheckF checkExpr body) -> firstJust [checkExpr, body]
782+ UnprocessedParsedTermH ( HashF x) -> localTermDefinitionAt uri position env x
783783 UDTUPF names body -> localTermDefinitionAt uri position (foldr (`Map.insert` Nothing ) env names) body
784784 CaseUPF scrutinee cases ->
785785 localTermDefinitionAt uri position env scrutinee
0 commit comments