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

support for scoped type variables #85

Closed
jwiegley opened this issue Dec 31, 2021 · 0 comments · Fixed by #103
Closed

support for scoped type variables #85

jwiegley opened this issue Dec 31, 2021 · 0 comments · Fixed by #103
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jwiegley
Copy link

The following definition compiles in Agda (please ignore the lack of correctness for now):

{-# TERMINATING #-}
survey : {a : Set}  (Zipper a -> Zipper a) -> List a -> List a
survey {a} f = maybe [] go ∘ fromList
  where
    go : Zipper a  List a
    go z = let z' = f z in maybe (unzipper z') go (right z')
{-# COMPILE AGDA2HS survey #-}

But the resulting Haskell will not compile because of mismatched type variables:

survey :: (Zipper a -> Zipper a) -> [a] -> [a]
survey f = maybe [] go . fromList
  where
    go :: Zipper a -> [a]
    go z = maybe (unzipper (f z)) go (right (f z))

It should of course be, with ScopedTypeVariables enabled:

survey :: forall a. (Zipper a -> Zipper a) -> [a] -> [a]
survey f = maybe [] go . fromList
  where
    go :: Zipper a -> [a]
    go z = maybe (unzipper (f z)) go (right (f z))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants