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

Document alternative type declaration syntax #4882

Merged
merged 2 commits into from
Aug 28, 2020
Merged

Conversation

jpetkau
Copy link
Contributor

@jpetkau jpetkau commented Aug 7, 2020

In the introduction to syntax for declaring data types, document the ability
to declare types via constructor signatures in addition to the Haskell-like
syntax.

This syntax seems to be documented nowhere (not even in the book), and
is just used without explanation when introducing dependent types like
Fin that require it. From personal experience, this is extremely confusing
to newcomers to Idris.

(I'm not sure if this is the best place to document it, but it needs to be
somewhere where it will be easily found, and this is what comes up for
a Google search for "idris data types".)

jpetkau added 2 commits August 7, 2020 12:17
In the introduction to syntax for declaring data types, document the ability
to declare types via constructor signatures in addition to the Haskell-like
syntax.

This syntax seems to be documented nowhere (not even in the book), and
is just used without explanation when introducing dependent types like
`Fin` that require it. From personal experience, this is *extremely* confusing
to newcomers to Idris.

(I'm not sure if this is the best place to document it, but it needs to be
somewhere where it will be easily found, and this is what comes up for
a Google search for "idris data types".)
@LeifW
Copy link
Contributor

LeifW commented Aug 26, 2020

Thanks for the contribution - and sorry this didn't get attention earlier.
You're right - that syntax can be confusing when first encountering it - and I think examples showing the same data type defined both ways are helpful for those coming from e.g. Haskell.
Perhaps a mention of it being called GADT (in Haskell) or Agda syntax would be helpful, as in "The second, more general kind of data type, is defined using Agda or GADT style syntax. " - http://docs.idris-lang.org/en/latest/reference/syntax-guide.html#data-types

@LeifW
Copy link
Contributor

LeifW commented Aug 26, 2020

Or maybe just a link to the reference from the tutorial?
I think examples showing the same data type defined both ways would be helpful in the reference - not just showing things snipped from the existing library.
The current examples in the reference are useful for showing the why of GADTs, but not as much the how, i.e. how that "new" syntax maps to syntax they may already be familiar with.

@jfdm
Copy link
Contributor

jfdm commented Aug 27, 2020

Apologies that this has sat for a while.

These changes should be merged ASAP, they are important for making things clearer.

I think improving them with reference to 'GADT/Agda' style forms can come later.

@jfdm
Copy link
Contributor

jfdm commented Aug 27, 2020

If there are no objections from @jpetkau then I will merge tomorrow.

@jfdm jfdm self-assigned this Aug 27, 2020
@jfdm jfdm merged commit f904fbc into idris-lang:master Aug 28, 2020
@jfdm
Copy link
Contributor

jfdm commented Aug 28, 2020

@jpetkau Thanks! I've merged this now.

If anyone wants to implement the recommended improvements suggested by @LeifW then please go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants