Discussion:
[Agda] Agda's syntax declaration
Frederik Hanghøj Iversen
2017-11-03 13:06:09 UTC
Permalink
I recently discovered Agda's syntax directive. And just now discovered
that as a user I can define my own syntax directive.

The thing I'm talking about is exemplified in agda-stdlib in Data.Product:

Σ-syntax : ∀ {a b} (A : Set a) → (A → Set b) → Set (a ⊔ b)
Σ-syntax = Σ

syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B

Unfortunately I cannot find any documentation on this directive. If
anyone has a resource please let me know.

I was also wondering if it would be possible to use this directive to
define a syntactical construct for e.g. lists with arbitrary elements.
That is, I'd like to be able to write a syntax declaration allowing me
to write.

[0,1,2]

in stead of

0 ∷ 1 ∷ 2 ∷ []


Is this possible?
Andrea Vezzosi
2017-11-03 15:58:19 UTC
Permalink
Hi Frederik,

it seems like the only documentation was in the CHANGELOG, so I
collected it here:

https://github.com/agda/agda/blob/master/doc/user-manual/language/syntax-declarations.lagda.rst


it should soon appear at http://agda.readthedocs.io/ , I presume.

About the list syntax, I was able to find this gist, not sure how well
it works in practice though.

https://gist.github.com/bishboria/8568581

Cheers,
Andrea

On Fri, Nov 3, 2017 at 2:06 PM, Frederik Hanghøj Iversen
Post by Frederik Hanghøj Iversen
I recently discovered Agda's syntax directive. And just now discovered
that as a user I can define my own syntax directive.
Σ-syntax : ∀ {a b} (A : Set a) → (A → Set b) → Set (a ⊔ b)
Σ-syntax = Σ
syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B
Unfortunately I cannot find any documentation on this directive. If
anyone has a resource please let me know.
I was also wondering if it would be possible to use this directive to
define a syntactical construct for e.g. lists with arbitrary elements.
That is, I'd like to be able to write a syntax declaration allowing me
to write.
[0,1,2]
in stead of
0 ∷ 1 ∷ 2 ∷ []
Is this possible?
_______________________________________________
Agda mailing list
https://lists.chalmers.se/mailman/listinfo/agda
Nils Anders Danielsson
2017-11-03 21:51:45 UTC
Permalink
Post by Andrea Vezzosi
About the list syntax, I was able to find this gist, not sure how well
it works in practice though.
https://gist.github.com/bishboria/8568581
Note that regular list literals have the advantage that there is no need
to give parentheses around list elements, or around list literals.
--
/NAD
Martin Escardo
2017-11-03 22:37:18 UTC
Permalink
Can I say some things about Agda's syntax declaration?

* Why are the definitions backwards (what you define is in the
right-hand side)?

* There isn't any precise definition, as far as I know, of the syntax of
syntax.

* And there isn't much documentation, as discussed.

* And it is impossible to google search for "Agda syntax" (say) because
this gives answers about Agda's syntax, and not about the "syntax"
keyword. (And it doesn't help to search for "Agda syntax" or "Agda
syntax keyword" or "Agda syntax declaration".)

Anyway, after heroic guesswork, I managed to make some useful things to
work nicely using "syntax". (So thanks for implementing this feature!)

Definitely the most mysterious thing, to make such things work, was to
declare the (polymorphic) identity function as an infix left-associative
operator with priority 0:

infixl 0 id

This does work (for some things I've done), but I am not sure how I
figured it out (it is not documented), and I still don't know what
making the identity into an infix left-associative operator means.

:-)

Enjoy the weekend.

Best,
Martin
Post by Nils Anders Danielsson
Post by Andrea Vezzosi
About the list syntax, I was able to find this gist, not sure how well
it works in practice though.
https://gist.github.com/bishboria/8568581
Note that regular list literals have the advantage that there is no need
to give parentheses around list elements, or around list literals.
--
Martin Escardo
http://www.cs.bham.ac.uk/~mhe
Martin Escardo
2017-11-03 23:02:25 UTC
Permalink
Here is a particular (useful) concrete instance of the phenomenon I
discussed in the previous message:

```
id : {A : Type} → A → A
id {A} x = x

syntax id {A} x = x ∶ A

infixl 0 id
```

Here the symbol "∶" is the unicode one, not the Ascii one that is
built-in in Agda for type declarations.

This allows you to

* Say "x" with an explicit description of its type, by writing "x ∶ A"
(like in Haskell)

* This can be for clarity (the human reader of your Agda proof).

* For disambiguation (the computer reader of your Agda proof).

This also allows, with the associativity for id (!), to write things such as

* x ∶ A
∶ A'

to emphasize that the defined type of x is A, but is definitionally
equal to A' in a complex proof that we want not only Agda to approve of,
but also people to understand and appreciate.

Anyway, this was just a successful example of a use of "syntax", by
guesswork

Please, Agda developers, tell us the precise syntax of syntax.

Best,
Martin
Post by Martin Escardo
Can I say some things about Agda's syntax declaration?
* Why are the definitions backwards (what you define is in the
right-hand side)?
* There isn't any precise definition, as far as I know, of the syntax of
syntax.
* And there isn't much documentation, as discussed.
* And it is impossible to google search for "Agda syntax" (say) because
this gives answers about Agda's syntax, and not about the "syntax"
keyword. (And it doesn't help to search for "Agda syntax" or "Agda
syntax keyword" or "Agda syntax declaration".)
Anyway, after heroic guesswork, I managed to make some useful things to
work nicely using "syntax". (So thanks for implementing this feature!)
Definitely the most mysterious thing, to make such things work, was to
declare the (polymorphic) identity function as an infix left-associative
infixl 0 id
This does work (for some things I've done), but I am not sure how I
figured it out (it is not documented), and I still don't know what
making the identity into an infix left-associative operator means.
:-)
Enjoy the weekend.
Best,
Martin
Post by Nils Anders Danielsson
Post by Andrea Vezzosi
About the list syntax, I was able to find this gist, not sure how well
it works in practice though.
https://gist.github.com/bishboria/8568581
Note that regular list literals have the advantage that there is no need
to give parentheses around list elements, or around list literals.
--
Martin Escardo
http://www.cs.bham.ac.uk/~mhe
Martin Escardo
2017-11-03 23:03:40 UTC
Permalink
Sorry, Type was Set, I copied frin a development with adapting to this
context.

Type = Set.

M.
Post by Martin Escardo
Here is a particular (useful) concrete instance of the phenomenon I
```
id : {A : Type} → A → A
id {A} x = x
syntax id {A} x = x ∶ A
infixl 0 id
```
Here the symbol "∶" is the unicode one, not the Ascii one that is
built-in in Agda for type declarations.
This allows you to
* Say "x" with an explicit description of its type, by writing "x ∶ A"
(like in Haskell)
* This can be for clarity (the human reader of your Agda proof).
* For disambiguation (the computer reader of your Agda proof).
This also allows, with the associativity for id (!), to write things such as
* x ∶ A
∶ A'
to emphasize that the defined type of x is A, but is definitionally
equal to A' in a complex proof that we want not only Agda to approve of,
but also people to understand and appreciate.
Anyway, this was just a successful example of a use of "syntax", by
guesswork
Please, Agda developers, tell us the precise syntax of syntax.
Best,
Martin
Post by Martin Escardo
Can I say some things about Agda's syntax declaration?
* Why are the definitions backwards (what you define is in the
right-hand side)?
* There isn't any precise definition, as far as I know, of the syntax of
syntax.
* And there isn't much documentation, as discussed.
* And it is impossible to google search for "Agda syntax" (say) because
this gives answers about Agda's syntax, and not about the "syntax"
keyword. (And it doesn't help to search for "Agda syntax" or "Agda
syntax keyword" or "Agda syntax declaration".)
Anyway, after heroic guesswork, I managed to make some useful things to
work nicely using "syntax". (So thanks for implementing this feature!)
Definitely the most mysterious thing, to make such things work, was to
declare the (polymorphic) identity function as an infix left-associative
infixl 0 id
This does work (for some things I've done), but I am not sure how I
figured it out (it is not documented), and I still don't know what
making the identity into an infix left-associative operator means.
:-)
Enjoy the weekend.
Best,
Martin
Post by Nils Anders Danielsson
Post by Andrea Vezzosi
About the list syntax, I was able to find this gist, not sure how well
it works in practice though.
https://gist.github.com/bishboria/8568581
Note that regular list literals have the advantage that there is no need
to give parentheses around list elements, or around list literals.
--
Martin Escardo
http://www.cs.bham.ac.uk/~mhe
Martin Escardo
2017-11-03 23:05:56 UTC
Permalink
I shoudn't type so fast without reading what I wrote.

I copied from a development without adapting to this context.

This is what I meant to write.

M,
Post by Martin Escardo
Sorry, Type was Set, I copied frin a development with adapting to this
context.
Type = Set.
M.
Post by Martin Escardo
Here is a particular (useful) concrete instance of the phenomenon I
```
id : {A : Type} → A → A
id {A} x = x
syntax id {A} x = x ∶ A
infixl 0 id
```
Here the symbol "∶" is the unicode one, not the Ascii one that is
built-in in Agda for type declarations.
This allows you to
* Say "x" with an explicit description of its type, by writing "x ∶ A"
(like in Haskell)
* This can be for clarity (the human reader of your Agda proof).
* For disambiguation (the computer reader of your Agda proof).
This also allows, with the associativity for id (!), to write things such as
* x ∶ A
∶ A'
to emphasize that the defined type of x is A, but is definitionally
equal to A' in a complex proof that we want not only Agda to approve of,
but also people to understand and appreciate.
Anyway, this was just a successful example of a use of "syntax", by
guesswork
Please, Agda developers, tell us the precise syntax of syntax.
Best,
Martin
Post by Martin Escardo
Can I say some things about Agda's syntax declaration?
* Why are the definitions backwards (what you define is in the
right-hand side)?
* There isn't any precise definition, as far as I know, of the syntax of
syntax.
* And there isn't much documentation, as discussed.
* And it is impossible to google search for "Agda syntax" (say) because
this gives answers about Agda's syntax, and not about the "syntax"
keyword. (And it doesn't help to search for "Agda syntax" or "Agda
syntax keyword" or "Agda syntax declaration".)
Anyway, after heroic guesswork, I managed to make some useful things to
work nicely using "syntax". (So thanks for implementing this feature!)
Definitely the most mysterious thing, to make such things work, was to
declare the (polymorphic) identity function as an infix left-associative
infixl 0 id
This does work (for some things I've done), but I am not sure how I
figured it out (it is not documented), and I still don't know what
making the identity into an infix left-associative operator means.
:-)
Enjoy the weekend.
Best,
Martin
Post by Nils Anders Danielsson
Post by Andrea Vezzosi
About the list syntax, I was able to find this gist, not sure how well
it works in practice though.
https://gist.github.com/bishboria/8568581
Note that regular list literals have the advantage that there is no need
to give parentheses around list elements, or around list literals.
--
Martin Escardo
http://www.cs.bham.ac.uk/~mhe
Ulf Norell
2017-11-04 06:33:57 UTC
Permalink
Post by Martin Escardo
Can I say some things about Agda's syntax declaration?
* Why are the definitions backwards (what you define is in the
right-hand side)?
They're not. You are defining the syntax for a particular name in the same
way that
you define the value of a particular name (`syntax f x = bla` vs `f x =
bla`). If syntax
declarations were the other way around you would be very surprised to find
that you
can't have multiple syntax declarations for the same name (which you can't).
Post by Martin Escardo
* There isn't any precise definition, as far as I know, of the syntax of
syntax.
* And there isn't much documentation, as discussed.
What do you feel is missing from the documentation Andrea added [1], aside
from a more explicit explanation of what you are allowed to write in a
syntax
declaration?

[1] http://agda.readthedocs.io/en/latest/language/syntax-declarations.html
Post by Martin Escardo
* And it is impossible to google search for "Agda syntax" (say) because
this gives answers about Agda's syntax, and not about the "syntax"
keyword. (And it doesn't help to search for "Agda syntax" or "Agda
syntax keyword" or "Agda syntax declaration".)
Now you can do a page search in the user manual which should work better.
For future undocumented features your best bet when googling fails is to
grep the CHANGELOG.

Definitely the most mysterious thing, to make such things work, was to
Post by Martin Escardo
declare the (polymorphic) identity function as an infix left-associative
infixl 0 id
This does work (for some things I've done), but I am not sure how I
figured it out (it is not documented), and I still don't know what
making the identity into an infix left-associative operator means.
You answered this question yourself (and it's explained in the
Post by Martin Escardo
This also allows, with the associativity for id (!), to write things such
as
* x ∶ A
∶ A'
/ Ulf
Martin Escardo
2017-11-04 07:44:21 UTC
Permalink
Thanks for you answer, Ulf.
Post by Martin Escardo
Can I say some things about Agda's syntax declaration?
* Why are the definitions backwards (what you define is in the
right-hand side)?
They're not. You are defining the syntax for a particular name in the
same way that
you define the value of a particular name (`syntax f x = bla` vs `f x =
bla`). If syntax
declarations were the other way around you would be very surprised to
find that you
can't have multiple syntax declarations for the same name (which you can't).
I don't understand this remark. Consider again

```
id : {A : Type} → A → A
id {A} x = x

syntax id {A} x = x ∶ A

infixl 0 id
```

In the syntax definition, I have *already* define id (occurring in the
left-hand side), and the new thing I am *defining* in the syntax
declaration is ":", which occurs in the *right*-hand side.

At first I tried to define ":" to be left-associative, but this didn't
work. Then cheating from other people's examples I realized that one is
expected to define `id` to be left-associative. I didn't answer the
question myself as you suggest: I still don't know what it means for id
to be left-associative. :-) The above works and is useful, but I don't
understand it.

Best,
Martin
Ulf Norell
2017-11-04 09:29:41 UTC
Permalink
Ok, let me try to be more precise. In your example you are defining a
single thing (id)
with multiple properties. You can read it as something like this:

```
id.TYPE = {A : Type} → A → A
id.VALUE = {A} x ↩ x
id.SYNTAX = {A} x ↩ x "∶" A
id.FIXITY = infixl 0
```

Contrary to your intuition "∶" is not a thing in its own right, but simply
a terminal symbol in
the parsing rule for id.

/ Ulf
Post by Martin Escardo
Thanks for you answer, Ulf.
Post by Martin Escardo
Can I say some things about Agda's syntax declaration?
* Why are the definitions backwards (what you define is in the
right-hand side)?
They're not. You are defining the syntax for a particular name in the
same way that
you define the value of a particular name (`syntax f x = bla` vs `f x =
bla`). If syntax
declarations were the other way around you would be very surprised to
find that you
can't have multiple syntax declarations for the same name (which you can't).
I don't understand this remark. Consider again
```
id : {A : Type} → A → A
id {A} x = x
syntax id {A} x = x ∶ A
infixl 0 id
```
In the syntax definition, I have *already* define id (occurring in the
left-hand side), and the new thing I am *defining* in the syntax
declaration is ":", which occurs in the *right*-hand side.
At first I tried to define ":" to be left-associative, but this didn't
work. Then cheating from other people's examples I realized that one is
expected to define `id` to be left-associative. I didn't answer the
question myself as you suggest: I still don't know what it means for id to
be left-associative. :-) The above works and is useful, but I don't
understand it.
Best,
Martin
Wolfram Kahl
2017-11-04 14:58:57 UTC
Permalink
Post by Ulf Norell
Ok, let me try to be more precise. In your example you are defining a
single thing (id)
```
id.TYPE = {A : Type} → A → A
id.VALUE = {A} x ↦ x
id.SYNTAX = {A} x ↦ x "∶" A
id.FIXITY = infixl 0
```
Contrary to your intuition "∶" is not a thing in its own right, but simply
a terminal symbol in
the parsing rule for id.
Saying ``the parsing rule for id'' might be a bit misleading currently,
since ``id'' still continues to be parsed without problems.


My pragmatic recommendation for syntax declarations is
to never attach syntax to an identifier that will still be used
for other purposes, including that it needs to be visible for export.

For example, you could write:

```
id : {A : Type} → A → A
id {A} x = x

idViaColon : {A : Type} → A → A
idViaColon = id

-- the following clause augments the definition of the meta-function
-- `syntax` by one more pattern-matching clause,
-- where the type of the first argument is the meta-type `identifier`
-- ;-)
--
syntax idViaColon {A} x = x ∶ A


infixl 0 idViaColon
```

Then users of your library can decide whether they just want TYPE and VALUE
of `id`, and import only that, or they only want SYNTAX and FIXITY of `idViaColon`
(with the VALUE and TYPE of `id` attached), and they would then import only `idViaColon`,
or in some cases they might import both.

With that kind of usage pattern for syntax, I would not even object to
actually making the syntax declaration ``the'' parsing rule for `idViaColon`,
and thus making that identifier unavailable otherwise, except in import lists.


Wolfram
Andreas Abel
2017-11-06 09:08:34 UTC
Permalink
I must say I am with Martin on this. I never understood why the syntax
declarations are backwards. The usual mathematical style is that you
introduce a notation and what it expands to. It is the notation which
is the new thing and whose meaning is defined in terms of things
understood before, and the defined thing is commonly on the left hand
side of the =.

And Ulf, your explanation is very implementation-centric.

I think it was easiest for the user, if declarations of the form

lhs = rhs

could be uniformly be understood as "rewrite lhs to rhs if you are stuck
on with something involving lhs".

If we take a step back, there is two things that we would want from a
notation introduced by a syntax declaration:

1. Have Agda parse it.
2. Have Agda use it when it prints stuff to us.

For 1. it is perfectly fine to have several notations that expand to the
same function symbol or function application.

For 2. having several notations for the same function symbol leads to
more ambiguity. (There is already some ambiguity, because Agda could
print the original function symbol or use the notation.)

As it stands, I deem goal 1. higher in practice, and also, it works
better. For 2. there is an overlapping feature, DISPLAY pragmas, which
can sometimes be used to fix up the printing. (Note that for the
display pragma, DISPLAY lhs = rhs, means "rewrite lhs to rhs for the
purpose of printing", which is the intuitive reading.)

Also, goal 2. does seem to be achieved in practice. For instance,
trying the notation for the Sigma type in Data.Product:

open import Data.Product

goal : ∀{A : Set}{B : A → Set} → Σ[ x ∈ A ] B x
goal = {!!}

Agda prints the goal as

Σ-syntax .A .B

In this case, DISPLAY does not help either,

{-# DISPLAY Σ-syntax A B = Σ[ x ∈ A ] B x #-}

as Agda reports

Not allowed in DISPLAY pragma right-hand side: lambdas
when checking the pragma
DISPLAY Σ-syntax A B = Σ-syntax A λ x → B x

Since the "syntax" facility does not work properly, I don't use it.
Well, the father of the syntax facility ran away soon after the conception.

Cheers,
Andreas

P.S.: Martin, for now you should just memorize to read

syntax lhs = rhs

as "a new syntax for lhs is rhs".
Post by Ulf Norell
Ok, let me try to be more precise. In your example you are defining a
single thing (id)
```
id.TYPE = {A : Type} → A → A
id.VALUE = {A} x ↦ x
id.SYNTAX = {A} x ↦ x "∶" A
id.FIXITY = infixl 0
```
Contrary to your intuition "∶" is not a thing in its own right, but
simply a terminal symbol in
the parsing rule for id.
/ Ulf
Thanks for you answer, Ulf.
On Fri, Nov 3, 2017 at 11:37 PM, Martin Escardo
    Can I say some things about Agda's syntax declaration?
    * Why are the definitions backwards (what you define is in the
    right-hand side)?
They're not. You are defining the syntax for a particular name
in the same way that
you define the value of a particular name (`syntax f x = bla` vs
`f x = bla`). If syntax
declarations were the other way around you would be very
surprised to find that you
can't have multiple syntax declarations for the same name (which
you can't).
I don't understand this remark. Consider again
```
id : {A : Type} → A → A
id {A} x = x
syntax id {A} x = x ∶ A
infixl 0 id
```
In the syntax definition, I have *already* define id (occurring in
the left-hand side), and the new thing I am *defining* in the syntax
declaration is ":", which occurs in the *right*-hand side.
At first I tried to define ":" to be left-associative, but this
didn't work. Then cheating from other people's examples I realized
that one is expected to define `id` to be left-associative. I didn't
answer the question myself as you suggest: I still don't know what
it means for id to be left-associative. :-) The above works and is
useful, but I don't understand it.
Best,
Martin
_______________________________________________
Agda mailing list
https://lists.chalmers.se/mailman/listinfo/agda
--
Andreas Abel <>< Du bist der geliebte Mensch.

Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden

***@gu.se
http://www.cse.chalmers.se/~abela/
Ulf Norell
2017-11-06 10:09:48 UTC
Permalink
Post by Andreas Abel
I must say I am with Martin on this. I never understood why the syntax
declarations are backwards. The usual mathematical style is that you
introduce a notation and what it expands to. It is the notation which is
the new thing and whose meaning is defined in terms of things understood
before, and the defined thing is commonly on the left hand side of the =.
And Ulf, your explanation is very implementation-centric.
Indeed, my explanation was of what's actually implemented in Agda at the
moment. One can certainly imagine other syntax extension mechanisms that
may or may not be easier to grasp for a user.

I'm still not sure why the "parsing rule" intuition doesn't work for you.
No one writes grammars with the new syntax in the left-hand side.

/ Ulf

Frederik Hanghøj Iversen
2017-11-04 11:42:01 UTC
Permalink
This is really great. Thank you for putting this in the docs. I'll be sure
to search the changelog next time I run into an undocumented feature.

As for the documentation I think this example:

syntax _==_ x y = x === y


Could benefit from a change. As far as I understand it the issue with this
declaration is the LHS, i.e. _==_ and not the RHS ===, but I could be
wrong. So perhaps it's a bit misleading.

Maybe linking the gist for list-syntax would also be helpful (perhaps even
adding it to agda-stdlib?) And the documentation could also expand on the
caveat of using this approach as pointed out by NAD here and Toxaris in the
Gist.

Also, it's a bit funny to me that so many readthedocs articles have the
disclaimer "this is a stub" xD
Post by Andrea Vezzosi
Hi Frederik,
it seems like the only documentation was in the CHANGELOG, so I
https://github.com/agda/agda/blob/master/doc/user-manual/
language/syntax-declarations.lagda.rst
it should soon appear at http://agda.readthedocs.io/ , I presume.
About the list syntax, I was able to find this gist, not sure how well
it works in practice though.
https://gist.github.com/bishboria/8568581
Cheers,
Andrea
On Fri, Nov 3, 2017 at 2:06 PM, Frederik HanghÞj Iversen
Post by Frederik Hanghøj Iversen
I recently discovered Agda's syntax directive. And just now discovered
that as a user I can define my own syntax directive.
The thing I'm talking about is exemplified in agda-stdlib in
Σ-syntax : ∀ {a b} (A : Set a) → (A → Set b) → Set (a ⊔ b)
Σ-syntax = Σ
syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B
Unfortunately I cannot find any documentation on this directive. If
anyone has a resource please let me know.
I was also wondering if it would be possible to use this directive to
define a syntactical construct for e.g. lists with arbitrary elements.
That is, I'd like to be able to write a syntax declaration allowing me
to write.
[0,1,2]
in stead of
0 ∷ 1 ∷ 2 ∷ []
Is this possible?
_______________________________________________
Agda mailing list
https://lists.chalmers.se/mailman/listinfo/agda
--
Regards
*Frederik HanghÞj Iversen*
Andrea Vezzosi
2017-11-05 10:14:21 UTC
Permalink
Indeed the "syntax _==_ x y = x === y" example could be changed to
"syntax _>>=_ e₁ (λ x → e₂) = x ← e₁ , e₂" to highlight what the
problem is, as compared to bind above.


By the way, if you find more to add to the docs feel free to send pull
requests :) We might get rid of some of those stubs one day.

Cheers,
Andrea


On Sat, Nov 4, 2017 at 12:42 PM, Frederik Hanghøj Iversen
Post by Frederik Hanghøj Iversen
This is really great. Thank you for putting this in the docs. I'll be sure
to search the changelog next time I run into an undocumented feature.
syntax _==_ x y = x === y
Could benefit from a change. As far as I understand it the issue with this
declaration is the LHS, i.e. _==_ and not the RHS ===, but I could be wrong.
So perhaps it's a bit misleading.
Maybe linking the gist for list-syntax would also be helpful (perhaps even
adding it to agda-stdlib?) And the documentation could also expand on the
caveat of using this approach as pointed out by NAD here and Toxaris in the
Gist.
Also, it's a bit funny to me that so many readthedocs articles have the
disclaimer "this is a stub" xD
Post by Andrea Vezzosi
Hi Frederik,
it seems like the only documentation was in the CHANGELOG, so I
https://github.com/agda/agda/blob/master/doc/user-manual/language/syntax-declarations.lagda.rst
it should soon appear at http://agda.readthedocs.io/ , I presume.
About the list syntax, I was able to find this gist, not sure how well
it works in practice though.
https://gist.github.com/bishboria/8568581
Cheers,
Andrea
On Fri, Nov 3, 2017 at 2:06 PM, Frederik Hanghøj Iversen
Post by Frederik Hanghøj Iversen
I recently discovered Agda's syntax directive. And just now discovered
that as a user I can define my own syntax directive.
Σ-syntax : ∀ {a b} (A : Set a) → (A → Set b) → Set (a ⊔ b)
Σ-syntax = Σ
syntax Σ-syntax A (λ x → B) = Σ[ x ∈ A ] B
Unfortunately I cannot find any documentation on this directive. If
anyone has a resource please let me know.
I was also wondering if it would be possible to use this directive to
define a syntactical construct for e.g. lists with arbitrary elements.
That is, I'd like to be able to write a syntax declaration allowing me
to write.
[0,1,2]
in stead of
0 ∷ 1 ∷ 2 ∷ []
Is this possible?
_______________________________________________
Agda mailing list
https://lists.chalmers.se/mailman/listinfo/agda
--
Regards
Frederik Hanghøj Iversen
Loading...