Inconvenient definition for NDBType.asType
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Área
- documentation
Línea de trabajo
Comienza con el ejercicio Typed Queries y compara la definición condicional de NDBType.asType con la alternativa basada en pattern matching mostrada en el issue. Revisa la implementación relacionada de NDBType.beq y el resto del ejercicio nullable-types. Se considera terminado cuando la definición admite comparaciones directas mediante pattern matching sin los casts ni los workarounds de tácticas indicados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Lean
- Estrellas
- 211
- Forks
- 83
- Merge medio
- 8 min
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de leanprover/fp-lean
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 84/100
leanprover/fp-lean#316 ·
-
Typo
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
leanprover/fp-lean#311 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
leanprover/fp-lean#304 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
leanprover/fp-lean#303 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
leanprover/fp-lean#301 · 1 comentario ·
Todos los issues de leanprover/fp-lean
Issues similares
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
Eq のコンストラクタから定義的等価という話につなげるAbierto優先度たかし
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
lean-ja/lean-by-example#2681 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
laststance/design-world#79 ·
Los mantenedores suelen responder en 1 día
-
v2
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
modelcontextprotocol/python-sdk#3978 · 2 comentarios ·
Los mantenedores suelen responder en 1 día