File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ import Foreign.Object.ST as FOST
39
39
import Prim.Row as Row
40
40
import Record as Record
41
41
import Type.Proxy (Proxy (..))
42
+ import Unsafe.Coerce (unsafeCoerce )
42
43
43
44
-- | A helper for defining JSON codecs for "enum" sum types, where every
44
45
-- | constructor is nullary, and the type will be encoded as a string.
@@ -217,7 +218,7 @@ instance gCasesSum ∷
217
218
let
218
219
codecs1 = Record .get (Proxy @name) r ∷ codecs1
219
220
r1 = Record .insert (Proxy @name) codecs1 {} ∷ Record r1
220
- r2 = Record .delete (Proxy @name) r ∷ Record r2
221
+ r2 = unsafeDelete (Proxy @name) r ∷ Record r2
221
222
in
222
223
case _ of
223
224
Inl lhs → gCasesEncode encoding r1 lhs
@@ -391,3 +392,8 @@ encodeSumCase encoding tag jsons =
391
392
in
392
393
encode jobject $ Obj .fromFoldable $ catMaybes
393
394
[ tagEntry, valEntry ]
395
+
396
+ -- | Same as `Record.delete` deleting only happens at the type level
397
+ -- | and the value is left untouched.
398
+ unsafeDelete ∷ ∀ r1 r2 l a . IsSymbol l ⇒ Row.Lacks l r1 ⇒ Row.Cons l a r1 r2 ⇒ Proxy l → Record r2 → Record r1
399
+ unsafeDelete _ r = unsafeCoerce r
You can’t perform that action at this time.
0 commit comments