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

Feature request: implicit lambda arguments syntax #4591

Open
andreykl opened this issue Nov 17, 2018 · 2 comments
Open

Feature request: implicit lambda arguments syntax #4591

andreykl opened this issue Nov 17, 2018 · 2 comments

Comments

@andreykl
Copy link

andreykl commented Nov 17, 2018

I faced a strange behavior when I was trying to get an implicit variable.

Steps to Reproduce

module ImplicitCatchImp

All : (a : i -> Type) -> Type
All a {i} = {j : i} -> a j

infixr 1 :->

(:->) : (a, b : i -> Type) -> (i -> Type)
(:->) a b i = a i -> b i

record Parser (a : Type) (n : Nat) where
  constructor MkParser
  RunParser : List Char -> List a
  
guardM : (a -> Maybe b) -> All (Parser a :-> Parser b)
guardM f {a} {b} = ?guardM_rhs

This is how the hole looks like

 ImplicitCatchImp.guardM_rhs [P]
 `--                            b : Type
                                a : Type
                                f : a -> Maybe b
                                j : Nat
     --------------------------------------------------------
      ImplicitCatchImp.guardM_rhs : Parser a j -> Parser b j

So, everything is just as it should be (as I see). Now, I try to access j:

guardM : (a -> Maybe b) -> All (Parser a :-> Parser b)
guardM f {a} {b} {j} = ?guardM_rhs

And this is how the hole looks like now

- + ImplicitCatchImp.guardM_rhs [P]
 `--                            j : Type
                                b : Type
                                a : b -> Maybe j
                               j1 : Nat
                                f : Parser b j1
     --------------------------------------------
      ImplicitCatchImp.guardM_rhs : Parser j j1

So, it renamed j to j1 and I'm not able to get access to it. When I try to get j1 it answers that j1 is not an implicit argument of ImplicitCatchImp.guardM. That is true...

Expected Behavior

j of type Nat should be in scope

Observed Behavior

j has type Type and needed variable is ranamed to j1

There are many issues with implicit arguments but I think most close to this one are #2258 and #4206

@andreykl andreykl changed the title unable go get implicit variable unable to get implicit variable Nov 17, 2018
@clayrat
Copy link
Contributor

clayrat commented Nov 17, 2018

The syntax you need here is guardM f {a} {b} = \{j} => ... aka implicit lambda arguments, but this is currently not supported and, from what I understand, is likely to not be added before Idris 2.

@andreykl andreykl changed the title unable to get implicit variable Feature request: implicit lambda arguments syntax Nov 17, 2018
@andreykl
Copy link
Author

Thank you! I was confused with this a bit. Should I leave the issue as a feature request?

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

2 participants