on master help sign in
Remove (:=:) alias
commit5badc4958894b4afe97c937e0d221dd1d6aca05e authorSridhar Ratnakumar <srid@srid.ca> dateFri 31 Jul 2020, 18:17 (6 years ago) parent451841c
2 files changed+24−33
src/JRec.hs+2−11 test/JRecSpec.hs+22−22
src/JRec.hs+2−11
@@ -5,11 +5,10 @@
55module JRec
66 ( Record,
77 pattern Record,
8− (:=:),
9− pattern (:=:),
108 pattern ExactRecord,
119 unField,
1210 union,
11+ (:=)(..),
1312 )
1413where
1514
@@ -24,7 +23,7 @@ import GHC.TypeLits
2423import Generic.Data
2524import qualified JRec.Super as R
2625import Control.Lens ((&), (^.))
27−import JRec.Super ((:=))
26+import JRec.Super ((:=)(..))
2827import JRec.Tuple
2928import JRec.Field
3029import Unsafe.Coerce
@@ -50,14 +49,6 @@ instance
5049unField :: field ~ field' => R.FldProxy field -> (field' R.:= value) -> value
5150unField _ (_ R.:= value) = value
5251
53−----------------------------------------------------------------------------
54−-- Aliases
55−----------------------------------------------------------------------------
56−
57−type a :=: b = a := b
58−
59−pattern a :=: b = a R.:= b
60−
6152----------------------------------------------------------------------------
6253-- Other operations
6354----------------------------------------------------------------------------
test/JRecSpec.hs+22−22
@@ -7,37 +7,37 @@ import JRec
77spec :: Spec
88spec = do
99 it "polymorphic" $ do
10− (ExactRecord (#u :=: True, #a :=: 5, #b :=: 6) & #u .~ 5)
11− `shouldBe` ExactRecord (#u :=: 5, #a :=: 5, #b :=: 6)
10+ (ExactRecord (#u := True, #a := 5, #b := 6) & #u .~ 5)
11+ `shouldBe` ExactRecord (#u := 5, #a := 5, #b := 6)
1212 it "show" $ do
1313 show (ExactRecord ()) `shouldBe` "{}"
14− show (ExactRecord (#foo :=: True)) `shouldBe` "{foo = True}"
15− show (ExactRecord (#foo :=: True, #bar :=: 0)) `shouldBe` "{foo = True, bar = 0}"
14+ show (ExactRecord (#foo := True)) `shouldBe` "{foo = True}"
15+ show (ExactRecord (#foo := True, #bar := 0)) `shouldBe` "{foo = True, bar = 0}"
1616 it "get" $ do
17− let getA1 :: Record ("a" :=: Int ': rest) -> Int
17+ let getA1 :: Record ("a" := Int ': rest) -> Int
1818 getA1 = (^. #a)
19− let getA2 :: Record ("u" :=: Bool ': "a" :=: Int ': rest) -> Int
19+ let getA2 :: Record ("u" := Bool ': "a" := Int ': rest) -> Int
2020 getA2 = (^. #a)
21− getA1 (ExactRecord (#a :=: 5)) `shouldBe` 5
22− getA1 (ExactRecord (#a :=: 5, #b :=: 6)) `shouldBe` 5
23− getA2 (ExactRecord (#u :=: True, #a :=: 5)) `shouldBe` 5
24− getA2 (ExactRecord (#u :=: True, #a :=: 5, #b :=: 6)) `shouldBe` 5
21+ getA1 (ExactRecord (#a := 5)) `shouldBe` 5
22+ getA1 (ExactRecord (#a := 5, #b := 6)) `shouldBe` 5
23+ getA2 (ExactRecord (#u := True, #a := 5)) `shouldBe` 5
24+ getA2 (ExactRecord (#u := True, #a := 5, #b := 6)) `shouldBe` 5
2525 it "set" $ do
2626 let setA1 ::
27− Record ("a" :=: Int ': rest) ->
28− Record ("a" :=: Int ': rest)
27+ Record ("a" := Int ': rest) ->
28+ Record ("a" := Int ': rest)
2929 setA1 = (#a .~ 8)
3030 let setA2 ::
31− Record ("u" :=: Bool ': "a" :=: Int ': rest) ->
32− Record ("u" :=: Bool ': "a" :=: Int ': rest)
31+ Record ("u" := Bool ': "a" := Int ': rest) ->
32+ Record ("u" := Bool ': "a" := Int ': rest)
3333 setA2 = (#a .~ 8)
34− setA1 (ExactRecord (#a :=: 5))
35− `shouldBe` (ExactRecord (#a :=: 8))
36− setA1 (ExactRecord (#a :=: 5, #b :=: 6))
37− `shouldBe` (ExactRecord (#a :=: 8, #b :=: 6))
38− setA2 (ExactRecord (#u :=: True, #a :=: 5))
39− `shouldBe` (ExactRecord (#u :=: True, #a :=: 8))
40− setA2 (ExactRecord (#u :=: True, #a :=: 5, #b :=: 6))
41− `shouldBe` (ExactRecord (#u :=: True, #a :=: 8, #b :=: 6))
34+ setA1 (ExactRecord (#a := 5))
35+ `shouldBe` (ExactRecord (#a := 8))
36+ setA1 (ExactRecord (#a := 5, #b := 6))
37+ `shouldBe` (ExactRecord (#a := 8, #b := 6))
38+ setA2 (ExactRecord (#u := True, #a := 5))
39+ `shouldBe` (ExactRecord (#u := True, #a := 8))
40+ setA2 (ExactRecord (#u := True, #a := 5, #b := 6))
41+ `shouldBe` (ExactRecord (#u := True, #a := 8, #b := 6))
4242
4343