Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: compatibility shims for 2024-08-29 #40

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ jobs:
- "4.8.0"
- "4.9.0"
- "4.10.0"
- "4.11.0-rc1"
- "4.11.0-rc3"
- "nightly-2024-08-09"
- "nightly-2024-08-29"
platform:
- os: ubuntu-latest
installer: |
Expand Down
34 changes: 33 additions & 1 deletion src/compat/SubVerso/Compat.lean
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ elab "%first_succeeding" "[" es:term,* "]" : term <= ty => do
throwError m!"No alternative succeeded. Attempts were: " ++
indentD (MessageData.joinSep msgErrs Format.line)

scoped syntax "export_from_namespaces " "(" ident+ ") " "(" ident+ ")" : command

elab_rules : command
| `(export_from_namespaces ($nss*) ($xs*)) => do
let env ← getEnv
let mut toAlias := #[]
for x in xs do
let x' := x.getId
let mut found := none
for ns in nss do
let ns' := ns.getId
let y := ns' ++ x'
if env.contains y then
found := some (ns, x)
break
if let some ok := found then
toAlias := toAlias.push ok
else
throwErrorAt x "'{x}' not found in namespaces {indentD <| toMessageData nss}"
for (ns, x) in toAlias do
Command.elabCommand <| ← `(export $ns ($x))

open Command in
elab "%if_bound" x:ident cmd:command : command => do
if (← getEnv).contains x.getId then elabCommand cmd
Expand All @@ -71,7 +93,17 @@ def refIdentCase (ri : Lsp.RefIdent)
]

abbrev Parsec (α : Type) : Type :=
%first_succeeding [(Lean.Parsec α : Type), (Lean.Parsec String.Iterator α : Type)]
%first_succeeding [
(Lean.Parsec α : Type),
(Lean.Parsec String.Iterator α : Type),
(Std.Internal.Parsec String.Iterator α : Type)
]

namespace Parsec
export_from_namespaces
(Lean.Parsec.String Lean.Parsec Std.Internal.Parsec.String Std.Internal.Parsec)
(ws skipString skipChar many1Chars satisfy)
end Parsec

def HashMap := %first_succeeding [Std.HashMap, Lean.HashMap]
def HashSet := %first_succeeding [Std.HashSet, Lean.HashSet]
Expand Down
6 changes: 3 additions & 3 deletions src/examples/SubVerso/Examples/Slice.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Copyright (c) 2024 Lean FRO LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: David Thrane Christiansen
-/
import Lean.Data.Parsec
import Lean.Data.Json
import Lean.Data.Position
import Lean.Syntax
import Lean.Elab.Command
import SubVerso.Compat
import SubVerso.Examples.Slice.Attribute

open Lean (SourceInfo Syntax Environment FileMap MonadEnv MonadError MonadFileMap getFileMap getEnv nullKind)

open Lean hiding Parsec HashMap
open SubVerso.Compat (Parsec HashMap)

namespace SubVerso.Examples.Slice
Expand Down Expand Up @@ -71,7 +71,7 @@ deriving Repr
private def SliceCommand.beginRange := SliceCommand.mk true
private def SliceCommand.endRange := SliceCommand.mk false

open Lean.Parsec String in
open SubVerso.Compat.Parsec String in
private def sliceCommand (range : String.Range) : Parsec SliceCommand := do
ws
skipString "!!"
Expand Down
Loading