Skip to content

Commit fe6a098

Browse files
authored
Remove old generics (purescript#3007)
1 parent 0d1568f commit fe6a098

File tree

5 files changed

+15
-307
lines changed

5 files changed

+15
-307
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
-- @shouldFailWith CannotDerive
2+
module DeriveOldGeneric where
3+
4+
import Prelude
5+
import Data.Generic
6+
import Control.Monad.Eff.Console (log)
7+
8+
newtype Foo = Foo Int
9+
10+
derive instance genericFoo :: Generic Foo

examples/passing/2695.purs

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/passing/GenericsRep.purs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import Control.Monad.Eff.Console (CONSOLE, log, logShow)
66
import Data.Generic.Rep (class Generic)
77
import Data.Generic.Rep.Eq (genericEq)
88

9-
data X a = X a
10-
9+
data X a = X a
10+
1111
derive instance genericX :: Generic (X a) _
1212

1313
instance eqX :: Eq a => Eq (X a) where
@@ -33,31 +33,11 @@ newtype W = W { x :: Int, y :: MyString }
3333

3434
derive instance genericW :: Generic W _
3535

36-
instance eqW :: Eq W where
37-
eq x y = genericEq x y
38-
39-
data V = V { x :: Int } { x :: Int }
40-
41-
derive instance genericV :: Generic V _
42-
43-
instance eqV :: Eq V where
44-
eq x y = genericEq x y
45-
46-
newtype U = U {}
47-
48-
derive instance genericU :: Generic U _
49-
50-
instance eqU :: Eq U where
51-
eq x y = genericEq x y
52-
5336
main :: Eff (console :: CONSOLE) Unit
5437
main = do
5538
logShow (X 0 == X 1)
5639
logShow (X 1 == X 1)
5740
logShow (Z 1 Y == Z 1 Y)
5841
logShow (Z 1 Y == Y)
5942
logShow (Y == Y :: Y Z)
60-
logShow (W { x: 0, y: "A" } == W { x: 0, y: "A" })
61-
logShow (V { x: 0 } { x: 0 } == V { x: 0 } { x: 0 })
62-
logShow (U {} == U {})
6343
log "Done"
Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
module Records where
22

33
import Prelude
4-
import Data.Generic (class Generic, toSpine, GenericSpine(..))
54
import Control.Monad.Eff.Console (log)
65
import Test.Assert (assert')
76

87
newtype AstralKeys = AstralKeys { "💡" :: Int, "💢" :: Int }
98
newtype LoneSurrogateKeys = LoneSurrogateKeys { "\xdf06" :: Int, "\xd834" :: Int }
109

11-
derive instance genericAstralKeys :: Generic AstralKeys
12-
derive instance genericLoneSurrogateKeys :: Generic LoneSurrogateKeys
13-
14-
spineOf :: forall a. Generic a => a -> Unit -> GenericSpine
15-
spineOf x _ = toSpine x
16-
1710
testLoneSurrogateKeys =
1811
let
1912
expected = 5
@@ -40,27 +33,7 @@ testAstralKeys =
4033
case o."💡" of
4134
x -> { "💢": x }
4235

43-
testGenericLoneSurrogateKeys = do
44-
let expected = SProd "Records.LoneSurrogateKeys"
45-
[ \_ -> SRecord [ {recLabel: "\xd834", recValue: spineOf 1}
46-
, {recLabel: "\xdf06", recValue: spineOf 0}
47-
]
48-
]
49-
actual = toSpine (LoneSurrogateKeys { "\xdf06": 0, "\xd834": 1 })
50-
assert' ("generic lone surrogate keys: " <> show actual) (expected == actual)
51-
52-
testGenericAstralKeys = do
53-
let expected = SProd "Records.AstralKeys"
54-
[ \_ -> SRecord [ {recLabel: "💡", recValue: spineOf 0}
55-
, {recLabel: "💢", recValue: spineOf 1}
56-
]
57-
]
58-
actual = toSpine (AstralKeys { "💡": 0, "💢": 1 })
59-
assert' ("generic astral keys: " <> show actual) (expected == actual)
60-
6136
main = do
6237
testLoneSurrogateKeys
6338
testAstralKeys
64-
testGenericLoneSurrogateKeys
65-
testGenericAstralKeys
6639
log "Done"

0 commit comments

Comments
 (0)