Inconvenient definition for NDBType.asType
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 45/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Ambito
- documentation
Direzione di ricerca
Inizia con l’esercizio Typed Queries e confronta la definizione condizionale di NDBType.asType con l’alternativa basata sul pattern matching mostrata nell’issue. Controlla l’implementazione correlata di NDBType.beq e il resto dell’esercizio nullable-types. Il lavoro è completo quando la definizione supporta confronti diretti tramite pattern matching senza i casts o i workaround con le tactic segnalati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The following is given in the Typed Queries exercise
Nullable Types
Add support for nullable columns to the query language by representing database types with the following structure:
structure NDBType where
underlying : DBType
nullable : Bool
abbrev NDBType.asType (t : NDBType) : Type :=
if t.nullable then
Option t.underlying.asType
else
t.underlying.asType
Use this type in place of DBType in Column and DBExpr, and look up SQL's rules for NULL and comparison operators to determine the types of DBExpr's constructors.
It seems like Lean has issues seeing through this definition of .asType, which led to needing to use convoluted casting and tactics for the rest of the implementation.
For example, you can try to write NDBType.beq as:
def NDBType.beq (t : NDBType) (x y : t.asType) : Bool :=
match t with
| ⟨_, true⟩ => x == y
| ⟨_, false⟩ => x == y
However, Lean gives the errors:
failed to synthesize instance
BEq (asType { underlying := underlying✝, nullable := true })
failed to synthesize instance
BEq (asType { underlying := underlying✝, nullable := false })
Instead, I needed to write it as:
def NDBType.beq (t : NDBType) (x y : t.asType) : Bool :=
match t with
| ⟨t', true⟩ =>
let x' : Option t'.asType := x
x' == y
| ⟨t', false⟩ =>
let x' : t'.asType := x
x' == y
On the other hand, you can define NDBType.asType with:
abbrev NDBType.asType (t : NDBType) : Type :=
match t with
| ⟨t', true⟩ => Option t'.asType
| ⟨t', false⟩ => t'.asType
At this point, the first declaration of NDBType.beq works, as do the natural modifications needed for the rest of the exercise.
- Lingua principale
- Lean
- Stelle
- 211
- Fork
- 83
- Merge medio
- 8m
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/fp-lean
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 84/100
leanprover/fp-lean#316 ·
-
Typo
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
leanprover/fp-lean#311 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
leanprover/fp-lean#304 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
leanprover/fp-lean#303 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
leanprover/fp-lean#301 · 1 commento ·
Tutte le issue di leanprover/fp-lean
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Eq のコンストラクタから定義的等価という話につなげるAperta優先度たかし
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
lean-ja/lean-by-example#2681 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
laststance/design-world#79 ·
I maintainer di solito rispondono entro 1 giorno
-
v2
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
modelcontextprotocol/python-sdk#3978 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno