Skip to content

Commit 4998d83

Browse files
authored
[ git ] Merge pull request #28 from agda/agda-2.7.0
Upgrade Agda to v2.7.0.1
2 parents af389aa + 0fd129c commit 4998d83

File tree

14 files changed

+259
-41
lines changed

14 files changed

+259
-41
lines changed

package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: agda-language-server
2-
version: 0.2.6.4.3.0
2+
version: 0.2.7.0.1.0
33
github: "banacorn/agda-language-server"
44
license: MIT
55
author: "Ting-Gian LUA"

src/Agda.hs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import Agda.Compiler.Builtin ( builtinBackends )
1717
import Agda.Convert ( fromResponse )
1818
import Agda.Interaction.Base ( Command
1919
, Command'(Command, Done, Error)
20+
#if MIN_VERSION_Agda(2,7,0)
21+
#else
2022
, CommandM
23+
#endif
2124
, CommandState(optionsOnReload)
2225
, IOTCM
2326
, initCommandState
@@ -32,6 +35,10 @@ import Agda.Interaction.InteractionTop
3235
( initialiseCommandQueue
3336
, maybeAbort
3437
, runInteraction
38+
#if MIN_VERSION_Agda(2,7,0)
39+
, CommandM
40+
#else
41+
#endif
3542
)
3643
import Agda.Interaction.Options ( CommandLineOptions
3744
( optAbsoluteIncludePaths

src/Agda/Convert.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ import qualified Data.Map as Map
5858
import Data.String (IsString)
5959
import qualified Render
6060

61+
#if MIN_VERSION_Agda(2,7,0)
62+
import Agda.Interaction.Output ( OutputConstraint )
63+
#endif
64+
6165
responseAbbr :: IsString a => Response -> a
6266
responseAbbr res = case res of
6367
Resp_HighlightingInfo {} -> "Resp_HighlightingInfo"
@@ -67,6 +71,9 @@ responseAbbr res = case res of
6771
Resp_GiveAction {} -> "Resp_GiveAction"
6872
Resp_MakeCase {} -> "Resp_MakeCase"
6973
Resp_SolveAll {} -> "Resp_SolveAll"
74+
#if MIN_VERSION_Agda(2,7,0)
75+
Resp_Mimer {} -> "Resp_Mimer"
76+
#endif
7077
Resp_DisplayInfo {} -> "Resp_DisplayInfo"
7178
Resp_RunningInfo {} -> "Resp_RunningInfo"
7279
Resp_ClearRunningInfo {} -> "Resp_ClearRunningInfo"
@@ -97,6 +104,9 @@ fromResponse (Resp_GiveAction (InteractionId i) giveAction) =
97104
return $ IR.ResponseGiveAction i (fromAgda giveAction)
98105
fromResponse (Resp_MakeCase _ Function pcs) = return $ IR.ResponseMakeCaseFunction pcs
99106
fromResponse (Resp_MakeCase _ ExtendedLambda pcs) = return $ IR.ResponseMakeCaseExtendedLambda pcs
107+
#if MIN_VERSION_Agda(2,7,0)
108+
fromResponse (Resp_Mimer (InteractionId i) s) = return $ IR.ResponseMimer i s
109+
#endif
100110
fromResponse (Resp_SolveAll ps) = return $ IR.ResponseSolveAll (fmap prn ps)
101111
where
102112
prn (InteractionId i, e) = (i, prettyShow e)

src/Agda/IR.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ data Response
4040
ResponseMakeCaseFunction [String]
4141
| ResponseMakeCaseExtendedLambda [String]
4242
| ResponseSolveAll [(Int, String)]
43+
| ResponseMimer Int (Maybe String)
4344
| -- priority: 3
4445
ResponseJumpToError FilePath Int
4546
| ResponseEnd

src/Options.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ options =
5959
]
6060

6161
usage :: String
62-
usage = "Agda Language Server v0.0.3.0 \nUsage: als [Options...]\n"
62+
usage = "Agda v2.7.0.1 Language Server v0\nUsage: als [Options...]\n"
6363

6464
usageAboutAgdaOptions :: String
6565
usageAboutAgdaOptions =

src/Render/Class.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE FlexibleInstances #-}
33
{-# LANGUAGE TypeFamilies #-}
4-
{-# LANGUAGE TypeSynonymInstances #-}
54

65
module Render.Class
76
( Render (..),
@@ -78,6 +77,10 @@ instance Render Bool where
7877
instance Render Doc where
7978
render = text . Doc.render
8079

80+
instance Render a => Render (Maybe a) where
81+
renderPrec p Nothing = mempty
82+
renderPrec p (Just x) = renderPrec p x
83+
8184
instance Render a => Render [a] where
8285
render xs = "[" <> fsep (punctuate "," (fmap render xs)) <> "]"
8386
instance Render a => Render (List1 a) where

src/Render/Common.hs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,19 @@ import Agda.Syntax.Common
1616
Cohesion(..),
1717
QωOrigin(..),
1818
LensCohesion(getCohesion),
19-
NameId(..) )
19+
NameId(..),
20+
Erased(..), asQuantity, Lock(..), LockOrigin (..),
21+
#if MIN_VERSION_Agda(2,7,0)
22+
OverlapMode (..),
23+
#endif
24+
)
2025
import qualified Agda.Utils.Null as Agda
2126
import Agda.Utils.List1 (toList)
2227
import Agda.Utils.Functor ((<&>))
2328

2429
import Render.Class
2530
import Render.RichText
31+
import qualified Agda.Utils.List1 as List1
2632

2733
--------------------------------------------------------------------------------
2834

@@ -72,6 +78,19 @@ instance Render Cohesion where
7278

7379
--------------------------------------------------------------------------------
7480

81+
#if MIN_VERSION_Agda(2,7,0)
82+
instance Render OverlapMode where
83+
render = \case
84+
Overlappable -> "OVERLAPPABLE"
85+
Overlapping -> "OVERLAPPING"
86+
Incoherent -> "INCOHERENT"
87+
Overlaps -> "OVERLAPS"
88+
FieldOverlap -> "overlap"
89+
DefaultOverlap -> mempty
90+
#endif
91+
92+
--------------------------------------------------------------------------------
93+
7594
-- | From 'prettyHiding'
7695
-- @renderHiding info visible text@ puts the correct braces
7796
-- around @text@ according to info @info@ and returns
@@ -91,6 +110,17 @@ renderQuantity :: LensQuantity a => a -> Inlines -> Inlines
91110
renderQuantity a d =
92111
if show d == "_" then d else render (getQuantity a) <+> d
93112

113+
instance Render Lock where
114+
render = \case
115+
IsLock LockOLock -> "@lock"
116+
IsLock LockOTick -> "@tick"
117+
IsNotLock -> mempty
118+
119+
#if MIN_VERSION_Agda(2,7,0)
120+
renderErased :: Erased -> Inlines -> Inlines
121+
renderErased = renderQuantity . asQuantity
122+
#endif
123+
94124
renderCohesion :: LensCohesion a => a -> Inlines -> Inlines
95125
renderCohesion a d =
96126
if show d == "_" then d else render (getCohesion a) <+> d
@@ -102,6 +132,9 @@ instance (Render p, Render e) => Render (RewriteEqn' qn nm p e) where
102132
render = \case
103133
Rewrite es -> prefixedThings (text "rewrite") (render . snd <$> toList es)
104134
Invert _ pes -> prefixedThings (text "invert") (toList pes <&> (\ (p, e) -> render p <+> "<-" <+> render e) . namedThing)
135+
#if MIN_VERSION_Agda(2,7,0)
136+
LeftLet pes -> prefixedThings (text "using") [render p <+> "<-" <+> render e | (p, e) <- List1.toList pes]
137+
#endif
105138

106139
prefixedThings :: Inlines -> [Inlines] -> Inlines
107140
prefixedThings kw = \case

src/Render/Concrete.hs

Lines changed: 110 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import Agda.Utils.List1 as List1 (toList, fromList)
1717
import qualified Agda.Utils.List1 as List1
1818
import qualified Agda.Utils.List2 as List2
1919
import Agda.Utils.Float (toStringWithoutDotZero)
20-
import Agda.Utils.Function (applyWhen)
20+
import Agda.Utils.Function
21+
import Agda.Utils.Null
2122
import Agda.Utils.Functor (dget, (<&>))
2223
import Agda.Utils.Impossible (__IMPOSSIBLE__)
2324

@@ -27,9 +28,16 @@ import Render.Literal ()
2728
import Render.Name ()
2829
import Render.RichText
2930
import Render.TypeChecking ()
31+
import Prelude hiding (null)
3032

3133
--------------------------------------------------------------------------------
3234

35+
#if MIN_VERSION_Agda(2,7,0)
36+
instance Render a => Render (TacticAttribute' a) where
37+
render (TacticAttribute t) =
38+
ifNull (render t) empty $ \ d -> "@" <> parens ("tactic" <+> d)
39+
#endif
40+
3341
instance Render a => Render (Ranged a) where
3442
render = render . rangedThing
3543

@@ -172,6 +180,28 @@ instance Render a => Render (Binder' a) where
172180

173181
-- | NamedBinding
174182
instance Render NamedBinding where
183+
#if MIN_VERSION_Agda(2,7,0)
184+
render (NamedBinding withH
185+
x@(Arg (ArgInfo h (Modality r q c) _o _fv (Annotation lock))
186+
(Named _mn xb@(Binder _mp (BName _y _fix t _fin))))) =
187+
applyWhen withH prH $
188+
applyWhenJust (isLabeled x) (\ l -> (text l <+>) . ("=" <+>)) (render xb)
189+
-- isLabeled looks at _mn and _y
190+
-- pretty xb prints also the pattern _mp
191+
where
192+
prH = (render r <>)
193+
. renderHiding h mparens
194+
. (coh <+>)
195+
. (qnt <+>)
196+
. (lck <+>)
197+
. (tac <+>)
198+
coh = render c
199+
qnt = render q
200+
tac = render t
201+
lck = render lock
202+
-- Parentheses are needed when an attribute @... is printed
203+
mparens = applyUnless (null coh && null qnt && null lck && null tac) parens
204+
#else
175205
render (NamedBinding withH x) =
176206
prH $
177207
if
@@ -192,13 +222,20 @@ instance Render NamedBinding where
192222
mparens'
193223
| noUserQuantity x, Nothing <- bnameTactic bn = id
194224
| otherwise = parens
225+
#endif
195226

196227
renderTactic :: BoundName -> Inlines -> Inlines
197228
renderTactic = renderTactic' . bnameTactic
198229

199230
renderTactic' :: TacticAttribute -> Inlines -> Inlines
231+
#if MIN_VERSION_Agda(2,7,0)
232+
renderTactic' t = (render t <+>)
233+
#else
200234
renderTactic' Nothing d = d
201235
renderTactic' (Just t) d = "@" <> (parens ("tactic " <> render t) <+> d)
236+
#endif
237+
238+
202239

203240
--------------------------------------------------------------------------------
204241

@@ -266,6 +303,17 @@ instance Render WhereClause where
266303
| isNoName (unqualify x) =
267304
vcat ["where", vcat $ fmap render ds]
268305
render (AnyWhere _range ds) = vcat ["where", vcat $ fmap render ds]
306+
#if MIN_VERSION_Agda(2,7,0)
307+
render (SomeWhere _ erased m a ds) =
308+
vcat [ hsep $ privateWhenUserWritten a
309+
[ "module", renderErased erased (render m), "where" ]
310+
, vcat $ map render ds
311+
]
312+
where
313+
privateWhenUserWritten = \case
314+
PrivateAccess _ UserWritten -> ("private" :)
315+
_ -> id
316+
#else
269317
#if MIN_VERSION_Agda(2,6,4)
270318
render (SomeWhere _range _er m a ds) =
271319
#else
@@ -279,6 +327,7 @@ instance Render WhereClause where
279327
["module", render m, "where"],
280328
vcat $ fmap render ds
281329
]
330+
#endif
282331

283332
instance Render LHS where
284333
render (LHS p eqs es) =
@@ -343,10 +392,12 @@ instance Render Declaration where
343392
where
344393
mkInst (InstanceDef _) f = sep ["instance", f]
345394
mkInst NotInstanceDef f = f
346-
347-
mkOverlap j f
348-
| isOverlappable j = "overlap" <+> f
349-
| otherwise = f
395+
#if MIN_VERSION_Agda(2,7,0)
396+
mkOverlap i d | isYesOverlap i = "overlap" <+> d
397+
#else
398+
mkOverlap i d | isOverlappable i = "overlap" <+> d
399+
#endif
400+
| otherwise = d
350401
Field _ fs ->
351402
sep
352403
[ "field",
@@ -418,15 +469,25 @@ instance Render Declaration where
418469
render e
419470
]
420471
]
472+
473+
#if MIN_VERSION_Agda(2,7,0)
474+
Record _ erased x dir tel e cs -> pRecord erased x dir tel (Just e) cs
475+
#else
421476
#if MIN_VERSION_Agda(2,6,4)
422-
Record _ _er x dir tel e cs ->
477+
Record _ _er x dir tel e cs -> pRecord x dir tel (Just e) cs
423478
#else
424-
Record _ x dir tel e cs ->
479+
Record _ x dir tel e cs -> pRecord x dir tel (Just e) cs
425480
#endif
426-
pRecord x dir tel (Just e) cs
427-
RecordDef _ x dir tel cs ->
428-
pRecord x dir tel Nothing cs
481+
#endif
482+
#if MIN_VERSION_Agda(2,7,0)
483+
RecordDef _ x dir tel cs -> pRecord defaultErased x dir tel Nothing cs
484+
#else
485+
RecordDef _ x dir tel cs -> pRecord x dir tel Nothing cs
486+
#endif
487+
#if MIN_VERSION_Agda(2,7,0)
488+
#else
429489
RecordDirective r -> pRecordDirective r
490+
#endif
430491
Infix f xs -> render f <+> fsep (punctuate "," $ fmap render (toList xs))
431492
Syntax n _ -> "syntax" <+> render n <+> "..."
432493
PatternSyn _ n as p ->
@@ -511,6 +572,9 @@ pHasEta0 = \case
511572
YesEta -> "eta-equality"
512573
NoEta () -> "no-eta-equality"
513574

575+
instance Render RecordDirective where
576+
render = pRecordDirective
577+
514578
pRecordDirective ::
515579
RecordDirective ->
516580
Inlines
@@ -523,7 +587,36 @@ pRecordDirective = \case
523587
Eta eta -> pHasEta0 (rangedThing eta)
524588
PatternOrCopattern{} -> "pattern"
525589

526-
590+
#if MIN_VERSION_Agda(2,7,0)
591+
pRecord
592+
:: Erased
593+
-> Name
594+
-> [RecordDirective]
595+
-> [LamBinding]
596+
-> Maybe Expr
597+
-> [Declaration]
598+
-> Inlines
599+
pRecord erased x directives tel me ds = vcat
600+
[ sep
601+
[ hsep [ "record"
602+
, renderErased erased (render x)
603+
, fsep (map render tel)
604+
]
605+
, pType me
606+
]
607+
, vcat $ concat
608+
[ map render directives
609+
, map render ds
610+
]
611+
]
612+
where pType (Just e) = hsep
613+
[ ":"
614+
, render e
615+
, "where"
616+
]
617+
pType Nothing =
618+
"where"
619+
#else
527620
pRecord ::
528621
Name ->
529622
RecordDirectives ->
@@ -561,6 +654,7 @@ pRecord x (RecordDirectives ind eta pat con) tel me cs =
561654
YesEta -> "eta-equality"
562655
NoEta _ -> "no-eta-equality"
563656
pCon = maybeToList $ (("constructor" <+>) . render) . fst <$> con
657+
#endif
564658

565659
instance Render OpenShortHand where
566660
render DoOpen = "open"
@@ -607,6 +701,11 @@ instance Render Pragma where
607701
render (NotProjectionLikePragma _ q) =
608702
hsep [ "NOT_PROJECTION_LIKE", render q ]
609703
#endif
704+
#if MIN_VERSION_Agda(2,7,0)
705+
render (InjectiveForInferencePragma _ i) =
706+
hsep $ ["INJECTIVE_FOR_INFERENCE", render i]
707+
render (OverlapPragma _ x m) = hsep [render m, render x]
708+
#endif
610709

611710
instance Render Fixity where
612711
render (Fixity _ Unrelated _) = __IMPOSSIBLE__

0 commit comments

Comments
 (0)