-
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.
Use `unsafeCoerce` when there is an (erased) proof that types are identical. Fixes: #135
- Loading branch information
1 parent
a5683b4
commit ef4d175
Showing
8 changed files
with
53 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
open import Haskell.Prelude | ||
|
||
data A : Set where | ||
MkA : Nat → A | ||
|
||
data B : Set where | ||
MkB : Nat → B | ||
|
||
postulate A≡B : A ≡ B | ||
|
||
coerceExample : B | ||
coerceExample = coerce A≡B (MkA 5) | ||
|
||
{-# COMPILE AGDA2HS A newtype #-} | ||
{-# COMPILE AGDA2HS B newtype deriving (Show) #-} | ||
{-# COMPILE AGDA2HS coerceExample #-} |
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 |
---|---|---|
|
@@ -60,4 +60,5 @@ import Issue169 | |
import Issue210 | ||
import ModuleParameters | ||
import ModuleParametersImports | ||
import Coerce | ||
|
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,13 @@ | ||
module Coerce where | ||
|
||
import Numeric.Natural (Natural) | ||
import Unsafe.Coerce (unsafeCoerce) | ||
|
||
newtype A = MkA Natural | ||
|
||
newtype B = MkB Natural | ||
deriving (Show) | ||
|
||
coerceExample :: B | ||
coerceExample = unsafeCoerce (MkA 5) | ||
|
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
test/Fail/Issue142.agda:5,1-7 | ||
test/Fail/Issue142.agda:6,1-12 | ||
not supported by agda2hs: forced (dot) patterns in non-erased positions |