Skip to content

Commit 26b73d6

Browse files
committed
Update orphan instance check to use covering sets
1 parent 914481c commit 26b73d6

File tree

14 files changed

+125
-23
lines changed

14 files changed

+125
-23
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- @shouldFailWith OrphanInstance
2+
module Main where
3+
import Lib
4+
data L
5+
instance clr :: C L R
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Lib where
2+
-- covering sets: {{l}, {r}}
3+
class C l r | l -> r, r -> l
4+
data R
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- @shouldFailWith OrphanInstance
2+
module Test where
3+
import Lib
4+
instance c :: C
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module Lib where
2+
class C
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- @shouldFailWith OrphanInstance
2+
module Main where
3+
import Lib
4+
data R
5+
instance cflr :: C F L R
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Lib where
2+
-- covering sets: {{f, l}}
3+
class C f l r | l -> r
4+
data F
5+
data L
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Both f and l must be known, thus can be in separate modules
2+
module Main where
3+
import Control.Monad.Eff.Console (log)
4+
import Lib
5+
data F
6+
data R
7+
instance cflr :: C F L R
8+
main = log "Done"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Lib where
2+
-- covering sets: {{f, l}}
3+
class C f l r | l -> r
4+
data L
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- Both l and r must be known, thus can be in separate modules
2+
module Main where
3+
import Control.Monad.Eff.Console (log)
4+
import Lib
5+
data L
6+
instance clr :: C L R
7+
main = log "Done"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Lib where
2+
-- covering sets: {{l, r}}
3+
class C l r
4+
data R

0 commit comments

Comments
 (0)