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

Case split doesn't detect cases when working inside a namespace #3347

Open
JavierGelatti opened this issue Jul 7, 2024 · 0 comments
Open

Comments

@JavierGelatti
Copy link

Problem

If we define a type inside a namespace and it's not publicly exported, then we shouldn't be able to pattern match over its definition. This works fine, as the interactive editing tools don't offer the option to case split in that scenario.

The problem arises when trying to case split while being inside the same namespace (which should be possible, but it's not offered by the interactive tools).

Steps to Reproduce

Consider the following code:

import Data.Vect

namespace Stack
    Stack : Nat -> Type
    Stack n = Vect n String

    pop : Stack (S n) -> (String, Stack n)
    pop stack = ?pop_rhs
--      ^^^^^ trying to case split here

Expected Behavior

Case splitting should be possible, leaving the pop function like this:

    pop : Stack (S n) -> (String, Stack n)
    pop (x :: xs) = ?pop_rhs_0
--      ^^^^^^^^^

Observed Behavior

If we try to case split the stack parameter, no option is offered:
Example using the LSP from VSCode

Additional notes

Case splitting does work fine if we publicly export the definition of Stack:

import Data.Vect

namespace Stack
    public export
    Stack : Nat -> Type
    Stack n = Vect n String

    pop : Stack (S n) -> (String, Stack n)
    pop stack = ?pop_rhs
--      ^^^^^ trying to case split here works fine

Or when we're not working inside of a namespace:

import Data.Vect

Stack : Nat -> Type
Stack n = Vect n String

pop : Stack (S n) -> (String, Stack n)
pop stack = ?pop_rhs
--  ^^^^^ trying to case split here works fine

It also works fine by not allowing to case split if we're outside of the namespace and the definition was not publicly exported:

import Data.Vect

namespace Stack
    export
    Stack : Nat -> Type
    Stack n = Vect n String

pop : Stack (S n) -> (String, Stack n)
pop stack = ?pop_rhs_0
--  ^^^^^ trying to case split here does nothing, which is correct
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