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 generating RankN haskell types (using forall) #352

Closed
anka-213 opened this issue Aug 25, 2024 · 1 comment
Closed

Support generating RankN haskell types (using forall) #352

anka-213 opened this issue Aug 25, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@anka-213
Copy link
Member

For example, this agda code:

data MyBool : Set where
    MyTrue : MyBool
    MyFalse : MyBool
{-# COMPILE AGDA2HS MyBool #-}

exisitentialUse : ( (a : Set)  a  a)  MyBool
exisitentialUse f = f MyBool MyTrue
{-# COMPILE AGDA2HS exisitentialUse #-}

generates the following haskell code, which fails to compile

module Existential where

data MyBool = MyTrue | MyFalse

exisitentialUse :: (a -> a) -> MyBool
exisitentialUse f = f MyTrue

rather than the correct

module Existential where

data MyBool = MyTrue | MyFalse

exisitentialUse :: (forall a. a -> a) -> MyBool
exisitentialUse f = f MyTrue
@jespercockx
Copy link
Member

Yes, this seems like a great feature to support and not too difficult to add! We'd just have to keep track of whether we are currently at the top-level or in a nested position when compiling a type, and generate explicit foralls when required.

@jespercockx jespercockx added the enhancement New feature or request label Aug 26, 2024
@jespercockx jespercockx added this to the 1.4 milestone Aug 26, 2024
@anka-213 anka-213 self-assigned this Sep 20, 2024
@anka-213 anka-213 changed the title Support generating existentially qualified haskell types (using forall) Support generating RankN haskell types (using forall) Sep 20, 2024
anka-213 added a commit to anka-213/agda2hs that referenced this issue Sep 20, 2024
anka-213 added a commit to anka-213/agda2hs that referenced this issue Sep 20, 2024
jespercockx pushed a commit that referenced this issue Sep 23, 2024
@jespercockx jespercockx modified the milestones: 1.4, 1.3 Sep 24, 2024
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

No branches or pull requests

2 participants