-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [ re #169 ] Don't consider data/record modules as qualified imports * [ fix #169 ] Throw error when minimal record does not use named definition or \where
- Loading branch information
1 parent
8e7f12b
commit b9821f1
Showing
10 changed files
with
122 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
-- Using a default method implementation for an instance declaration currently | ||
-- requires a named definition or an anonymous `λ where` on the Agda side, so a | ||
-- record is not allowed. | ||
|
||
module Fail.Issue169-record where | ||
|
||
open import Haskell.Prelude | ||
|
||
record Identity (a : Set) : Set where | ||
field | ||
runIdentity : a | ||
open Identity public | ||
|
||
{-# COMPILE AGDA2HS Identity newtype #-} | ||
|
||
showIdentity : ⦃ Show a ⦄ → Identity a → String | ||
showIdentity record { runIdentity = id } = "Id < " ++ show id ++ " >" | ||
|
||
{-# COMPILE AGDA2HS showIdentity #-} | ||
|
||
instance | ||
iIdentityShow : ⦃ Show a ⦄ → Show (Identity a) | ||
iIdentityShow = record {Show₂ record {show = showIdentity}} | ||
|
||
{-# COMPILE AGDA2HS iIdentityShow #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
open import Haskell.Prelude | ||
|
||
record Identity (a : Set) : Set where | ||
field | ||
runIdentity : a | ||
open Identity public | ||
|
||
{-# COMPILE AGDA2HS Identity newtype #-} | ||
|
||
showIdentity : ⦃ Show a ⦄ → Identity a → String | ||
showIdentity record { runIdentity = id } = "Id < " ++ show id ++ " >" | ||
|
||
{-# COMPILE AGDA2HS showIdentity #-} | ||
|
||
instance | ||
iIdentityShow : ⦃ Show a ⦄ → Show (Identity a) | ||
iIdentityShow = record {Show₂ (λ where .Show₂.show → showIdentity)} | ||
|
||
{-# COMPILE AGDA2HS iIdentityShow #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,5 @@ import TypeOperatorImport | |
import IOFile | ||
import IOInput | ||
import Issue200 | ||
import Issue169 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test/Fail/Issue169-record.agda:22,3-16 | ||
illegal instance declaration: instances using default methods should use a named definition or an anonymous `λ where`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Issue169 where | ||
|
||
newtype Identity a = Identity{runIdentity :: a} | ||
|
||
showIdentity :: Show a => Identity a -> String | ||
showIdentity (Identity id) = "Id < " ++ show id ++ " >" | ||
|
||
instance (Show a) => Show (Identity a) where | ||
show = showIdentity | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters