I am trying to read the code for TinyIdris, but couldn't understand one of the first definitions about environments below (because of my lack of understanding about type-checking and/or dependent types):
public export
data Env : (tm : List Name -> Type) -> List Name -> Type where
Nil : Env tm []
(::) : Binder (tm vars) -> Env tm vars -> Env tm (x :: vars)
My current understanding is that the environment is for type-checking local variables. I thought it should be a dictionary from variable Name
s to types. And a Name
represents a variable.
I tried to guess the meaning from the types (some people claim they can), but couldn't make sense of it and it does not look like a dictionary or key-value pair of variable-types. I guess there are two questions here.
- Without prior knowledge, how should one read such a definition and understand it, say, well enough to give an example.
My main difficulty here is with the "undefined" variables such as x
(and tm
, vars
). They came out of now here. My best guess is that they are some kind of implicit variables. But it's difficult to understand what they are or their types are. Really, if one doesn't already know type-checking, how would one guess the meaning of these, and conclude that the Env
type does represent the data structure of a local environment.
- With prior knowledge, could someone help explain what these variables mean (
x, tm, vars
), and how to read this definition in English? And what is (or how to construct) an example value of this based on the type definition?
An addition question: if these "undefined" variables are indeed implicit ones, what are the benefits of writing them as implicits? I don't know about others. It made it quite difficult for me to understand.
Vec
. I am familiar with non-indexed inductive types such as binary trees. For the indexed inductive type, the multiple "undefined" variables made it difficult for me to guess the meaning of the overall type. They are probably not really undefined, they just appear without types, and I couldn't recover them. $\endgroup$