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

[ fix #373 ] enable existing-class on postulated type formers #374

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Agda2Hs/Compile/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ isClassName q = getConstInfo' q >>= \case
ClassPragma _ -> True
ExistingClassPragma -> True
_ -> False
Right Defn{defName = r, theDef = Axiom{}} -> processPragma r <&> (ExistingClassPragma ==)
_ -> return False

-- | Check if the given type corresponds to a class constraint in Haskell.
Expand Down
2 changes: 2 additions & 0 deletions test/AllTests.agda
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import CustomTuples
import ProjectionLike
import FunCon
import Issue308
import Issue373

{-# FOREIGN AGDA2HS
import Issue14
Expand Down Expand Up @@ -181,4 +182,5 @@ import CustomTuples
import ProjectionLike
import FunCon
import Issue308
import Issue373
#-}
21 changes: 21 additions & 0 deletions test/Issue373.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Issue373 where

open import Haskell.Prelude

{-# FOREIGN AGDA2HS

class MyShow a where
myshow :: a -> String

#-}

postulate
MyShow : Set → Set
myshow : {{ MyShow a }} → a → String

{-# COMPILE AGDA2HS MyShow existing-class #-}

anothershow : {{ MyShow a }} → a → String
anothershow = myshow

{-# COMPILE AGDA2HS anothershow #-}
1 change: 1 addition & 0 deletions test/golden/AllTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ import CustomTuples
import ProjectionLike
import FunCon
import Issue308
import Issue373

8 changes: 8 additions & 0 deletions test/golden/Issue373.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Issue373 where

class MyShow a where
myshow :: a -> String

anothershow :: MyShow a => a -> String
anothershow = myshow

Loading