Skip to content

Commit 72382c5

Browse files
phijor4e554c4c
authored andcommitted
Display list of possible constructors to introduce
When refining a goal whose type is a `data` type, and if there is more than one matching constructor, Agda replies with a list of possible constructors to introduce. We parse this reply and display the list of constructors in the info view. This fixes #141.
1 parent dca4bda commit 72382c5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Cornelis/Pretty.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ prettyGoals (InferredType ty) =
176176
prettyGoals (WhyInScope msg) = pretty msg
177177
prettyGoals (NormalForm expr) = pretty expr
178178
prettyGoals (DisplayError err) = annotate CornelisError $ pretty err
179+
prettyGoals (IntroConstructorUnknown constructors) = vsep
180+
[ annotate CornelisErrorWarning "Don't know which constructor to introduce."
181+
, mempty
182+
, section "Constructors available" constructors prettyName
183+
]
179184
prettyGoals (UnknownDisplayInfo v) = annotate CornelisError $ pretty $ show v
180185

181186
prettyInterval :: AgdaInterval -> Doc HighlightGroup

src/Cornelis/Types.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ data DisplayInfo
314314
| HelperFunction Text
315315
| InferredType Type
316316
| DisplayError Text
317+
| IntroConstructorUnknown [Text]
317318
| WhyInScope Text
318319
| NormalForm Text
319320
| UnknownDisplayInfo Value
@@ -339,6 +340,7 @@ instance FromJSON DisplayInfo where
339340
"Error" ->
340341
obj .: "error" >>= \err ->
341342
DisplayError <$> err .: "message"
343+
"IntroConstructorUnknown" -> IntroConstructorUnknown <$> obj .: "constructors"
342344
"InferredType" ->
343345
InferredType <$> obj .: "expr"
344346
"WhyInScope" ->

0 commit comments

Comments
 (0)