Skip to content

Commit

Permalink
[ fix #373 ] enable existing-class on postulated type formers
Browse files Browse the repository at this point in the history
  • Loading branch information
flupe committed Oct 1, 2024
1 parent 0412c42 commit dba6d18
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
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 #-}
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

0 comments on commit dba6d18

Please sign in to comment.