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

Improve an example in Basics/Namespace and modules #14

Open
DanielRrr opened this issue Jun 23, 2023 · 0 comments
Open

Improve an example in Basics/Namespace and modules #14

DanielRrr opened this issue Jun 23, 2023 · 0 comments

Comments

@DanielRrr
Copy link

DanielRrr commented Jun 23, 2023

The tutorial says

Each definition can be accompanied by \where block in the end. 
In contrast to Haskell, \where block is attached to the whole definition, not to a particular clause:

\func f => g \where \func g => 0

But this example doesn’t seem helpful in terms of demonstrating this feature of Arend. I would give an alternative example here. The Haskell definition of f would be exactly the same (modulo its syntax), so it’s worth giving an example containing many blocks. For example, the following is accepted in Haskell:

foo :: Int -> Int
foo 0 = bar 1
  where
  bar x = x + 2
foo n = bar (n + 2)
  where
  bar x = x + 2

Whereas the following is rejected since bar is not in scope in the first equation

foo :: Int -> Int
foo 0 = bar 1
foo n = bar (n + 2)
  where
  bar x = x + 2

But this is accepted in Arend:

\func foo (x : Nat) : Nat \elim x
  | 0 => bar 1
  | n => bar (n + 2)
    \where \func bar (x : Nat) => x + 2

This foo is off the top of my head, but it demonstrates that feature of Arend a bit better in my opinion.

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

No branches or pull requests

1 participant