@@ -10,12 +10,6 @@ module JRec
10 pattern ExactRecord,
10 pattern ExactRecord,
@@ -33,7 +27,6 @@ import Control.Lens ((&), (^.))
33import JRec.Super ((:=))
27import JRec.Super ((:=))
34import JRec.Tuple
28import JRec.Tuple
35import JRec.Field
29import JRec.Field
36−import Test.Tasty.HUnit
37import Unsafe.Coerce
30import Unsafe.Coerce
39----------------------------------------------------------------------------
32----------------------------------------------------------------------------
@@ -122,51 +115,6 @@ instance {-# OVERLAPPING #-} (R.Set field fields a' ~ fields', R.Set field field
122instance {-# OVERLAPPING #-} (R.Set field fields a ~ fields, R.Has field fields a) => GL.HasField' field (Record fields) a where
115instance {-# OVERLAPPING #-} (R.Set field fields a ~ fields, R.Has field fields a) => GL.HasField' field (Record fields) a where
123 field' = coerced @(Record fields) @_ @(R.Rec fields) @_ . R.lens (R.FldProxy @field)
116 field' = coerced @(Record fields) @_ @(R.Rec fields) @_ . R.lens (R.FldProxy @field)
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)
130−----------------------------------------------------------------------------
132−----------------------------------------------------------------------------
136− show (ExactRecord ()) @?= "{}"
137− show (ExactRecord (#foo :=: True)) @?= "{foo = True}"
138− show (ExactRecord (#foo :=: True, #bar :=: 0)) @?= "{foo = True, bar = 0}"
142− let getA1 :: Record ("a" :=: Int ': rest) -> Int
144− let getA2 :: Record ("u" :=: Bool ': "a" :=: Int ': rest) -> Int
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
154− Record ("a" :=: Int ': rest) ->
155− Record ("a" :=: Int ': rest)
158− Record ("u" :=: Bool ': "a" :=: Int ': rest) ->
159− Record ("u" :=: Bool ': "a" :=: Int ': rest)
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))
170pattern ExactRecord :: RecTuple tuple fields => tuple -> Record fields
118pattern ExactRecord :: RecTuple tuple fields => tuple -> Record fields
171pattern ExactRecord a <-
119pattern ExactRecord a <-
172 MkRecord (toTuple -> a)
120 MkRecord (toTuple -> a)