-
Notifications
You must be signed in to change notification settings - Fork 563
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow instances for synonyms (#3539)
* Allow instances for synonyms where the argument is fully determined * Fix again after merge * Remove determined-by-fundep requirement for synonym instances * Check instances after replacing type synonyms Co-authored-by: Ryan Hendrickson <ryan.hendrickson@alum.mit.edu> Co-authored-by: Harry Garrood <harry@garrood.me>
- Loading branch information
1 parent
7030486
commit ca39953
Showing
13 changed files
with
92 additions
and
66 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
2 changes: 1 addition & 1 deletion
2
tests/purs/failing/TypeSynonyms6.out → tests/purs/failing/TypeSynonymCycle.out
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
Error found: | ||
in module [33mMain[0m | ||
at tests/purs/failing/TypeSynonyms7.purs:8:1 - 9:14 (line 8, column 1 - line 9, column 14) | ||
|
||
Type class instance head is invalid due to use of type | ||
[33m [0m | ||
[33m ( x :: Int[0m | ||
[33m | r [0m | ||
[33m ) [0m | ||
[33m [0m | ||
All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form, unless the type is fully determined by other type class arguments via functional dependencies. | ||
|
||
in type class instance | ||
[33m [0m | ||
[33m Data.Show.Show (X r)[0m | ||
[33m [0m | ||
|
||
See https://github.com/purescript/documentation/blob/master/errors/InvalidInstanceHead.md for more information, | ||
or to contribute content related to this error. | ||
|
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,9 @@ | ||
-- @shouldFailWith InvalidInstanceHead | ||
module Main where | ||
|
||
import Prelude | ||
|
||
type X r = {x :: Int | r} | ||
|
||
instance showX :: Show (X r) where | ||
show _ = "" |
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,24 @@ | ||
Error found: | ||
in module [33mMain[0m | ||
at tests/purs/failing/TypeSynonymsOverlappingInstance.purs:14:1 - 15:16 (line 14, column 1 - line 15, column 16) | ||
|
||
Overlapping type class instances found for | ||
[33m [0m | ||
[33m Main.Convert String[0m | ||
[33m String[0m | ||
[33m [0m | ||
The following instances were found: | ||
|
||
Main.convertSB | ||
Main.convertSS | ||
|
||
|
||
in type class instance | ||
[33m [0m | ||
[33m Main.Convert String[0m | ||
[33m String[0m | ||
[33m [0m | ||
|
||
See https://github.com/purescript/documentation/blob/master/errors/OverlappingInstances.md for more information, | ||
or to contribute content related to this error. | ||
|
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,15 @@ | ||
-- @shouldFailWith OverlappingInstances | ||
module Main where | ||
|
||
import Prelude | ||
|
||
class Convert a b | a -> b where | ||
convert :: a -> b | ||
|
||
type Bar = String | ||
|
||
instance convertSB :: Convert String Bar where | ||
convert s = s | ||
|
||
instance convertSS :: Convert String String where | ||
convert s = s |
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 @@ | ||
module Main where | ||
|
||
import Prelude | ||
|
||
import Effect.Console (log) | ||
|
||
class Convert a b | a -> b where | ||
convert :: a -> b | ||
|
||
type Words = String | ||
|
||
instance convertSB :: Convert Int Words where | ||
convert 0 = "Nope" | ||
convert _ = "Done" | ||
|
||
main = log $ convert 1 |