@@ -10,12 +10,6 @@ module JRec
1010 pattern ExactRecord,
1111 unField,
1212 union,
13−
14− -- * Tests
15− unit_polymorphic,
16− unit_show,
17− unit_get,
18− unit_set,
1913 )
2014where
2115
@@ -33,7 +27,6 @@ import Control.Lens ((&), (^.))
3327import JRec.Super ((:=))
3428import JRec.Tuple
3529import JRec.Field
36−import Test.Tasty.HUnit
3730import Unsafe.Coerce
3831
3932----------------------------------------------------------------------------
@@ -122,51 +115,6 @@ instance {-# OVERLAPPING #-} (R.Set field fields a' ~ fields', R.Set field field
122115instance {-# OVERLAPPING #-} (R.Set field fields a ~ fields, R.Has field fields a) => GL.HasField' field (Record fields) a where
123116 field' = coerced @(Record fields) @_ @(R.Rec fields) @_ . R.lens (R.FldProxy @field)
124117
125−unit_polymorphic :: IO ()
126−unit_polymorphic = do
127− (ExactRecord (#u :=: True, #a :=: 5, #b :=: 6) & #u .~ 5)
128− @?= ExactRecord (#u :=: 5, #a :=: 5, #b :=: 6)
129−
130−----------------------------------------------------------------------------
131−-- Tests
132−----------------------------------------------------------------------------
133−
134−unit_show :: IO ()
135−unit_show = do
136− show (ExactRecord ()) @?= "{}"
137− show (ExactRecord (#foo :=: True)) @?= "{foo = True}"
138− show (ExactRecord (#foo :=: True, #bar :=: 0)) @?= "{foo = True, bar = 0}"
139−
140−unit_get :: IO ()
141−unit_get = do
142− let getA1 :: Record ("a" :=: Int ': rest) -> Int
143− getA1 = (^. #a)
144− let getA2 :: Record ("u" :=: Bool ': "a" :=: Int ': rest) -> Int
145− getA2 = (^. #a)
146− getA1 (ExactRecord (#a :=: 5)) @?= 5
147− getA1 (ExactRecord (#a :=: 5, #b :=: 6)) @?= 5
148− getA2 (ExactRecord (#u :=: True, #a :=: 5)) @?= 5
149− getA2 (ExactRecord (#u :=: True, #a :=: 5, #b :=: 6)) @?= 5
150−
151−unit_set :: IO ()
152−unit_set = do
153− let setA1 ::
154− Record ("a" :=: Int ': rest) ->
155− Record ("a" :=: Int ': rest)
156− setA1 = (#a .~ 8)
157− let setA2 ::
158− Record ("u" :=: Bool ': "a" :=: Int ': rest) ->
159− Record ("u" :=: Bool ': "a" :=: Int ': rest)
160− setA2 = (#a .~ 8)
161− setA1 (ExactRecord (#a :=: 5))
162− @?= (ExactRecord (#a :=: 8))
163− setA1 (ExactRecord (#a :=: 5, #b :=: 6))
164− @?= (ExactRecord (#a :=: 8, #b :=: 6))
165− setA2 (ExactRecord (#u :=: True, #a :=: 5))
166− @?= (ExactRecord (#u :=: True, #a :=: 8))
167− setA2 (ExactRecord (#u :=: True, #a :=: 5, #b :=: 6))
168− @?= (ExactRecord (#u :=: True, #a :=: 8, #b :=: 6))
169−
170118pattern ExactRecord :: RecTuple tuple fields => tuple -> Record fields
171119pattern ExactRecord a <-
172120 MkRecord (toTuple -> a)