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

Update TypeDD Chapter 11 for idris2 #2296

Merged
merged 2 commits into from
Jan 31, 2022
Merged

Conversation

trevarj
Copy link
Contributor

@trevarj trevarj commented Jan 30, 2022

There is a difference between idris1 and idris2 which breaks backwards compatibility when trying to implement (>>=) to use do notation for a custom type. See #1095 for details.

There is a difference between idris1 and idris2 which breaks backwards compatibility when trying to implement `(>>=)` to use `do` notation for a custom type. See idris-lang#1095 for details.
@trevarj
Copy link
Contributor Author

trevarj commented Jan 30, 2022

Can someone help clarify this sentence to make it more accurate?

When implementing (>>=) to support do notation for custom types, like RunIO, you must now add an extra data constructor (>>) to help desugaring.

@stefan-hoeck
Copy link
Contributor

How about:

In order to support do notation for custom types, you need to implement (>>=) for binding values in a do block and (>>) for sequencing computations without binding values.
For instance, the following do block is desugared to foo >>= (\x => bar >>= (\y => baz x y)):

do
  x <- foo
  y <- bar
  baz x y

while the following is converted to foo >> bar >> baz:

do
  foo
  bar
  baz

@trevarj
Copy link
Contributor Author

trevarj commented Jan 30, 2022

@stefan-hoeck this is perfect, thanks! Helps me immediately understand what the reason for adding the data constructor and >> is.

Copy link
Collaborator

@mattpolzin mattpolzin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition to the book notes. Thanks!

@mattpolzin mattpolzin merged commit a2c7e9f into idris-lang:main Jan 31, 2022
@trevarj trevarj deleted the patch-1 branch January 31, 2022 07:07
@gallais gallais added doc: typedd status: confirmed bug Something isn't working labels Jan 31, 2022
@gallais
Copy link
Member

gallais commented Jan 31, 2022

Thank you for the patch! Sorry I didn't think to fix the notes when I saw the typedd tests were failing. 😞

@trevarj
Copy link
Contributor Author

trevarj commented Jan 31, 2022

@gallais Not a problem. Happy to help and learn!

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

Successfully merging this pull request may close these issues.

4 participants