File tree Expand file tree Collapse file tree 2 files changed +4
-41
lines changed Expand file tree Collapse file tree 2 files changed +4
-41
lines changed Original file line number Diff line number Diff line change 1919 "purescript-sets" : " ^3.0.0" ,
2020 "purescript-unsafe-coerce" : " ^3.0.0" ,
2121 "purescript-transformers" : " ^3.0.0" ,
22- "purescript-symbols " : " ^3.0 .0"
22+ "purescript-record " : " ^0.2 .0"
2323 },
2424 "devDependencies" : {
2525 "purescript-console" : " ^3.0.0"
Original file line number Diff line number Diff line change 11module Data.Lens.Record (prop ) where
22
33import Prelude
4- import Data.StrMap as S
5- import Data.Lens (Lens , lens )
6- import Data.Maybe (fromJust )
7- import Data.Symbol (class IsSymbol , SProxy , reflectSymbol )
8- import Partial.Unsafe (unsafePartial )
9- import Unsafe.Coerce (unsafeCoerce )
10-
11- unsafeGet
12- :: forall r a
13- . String
14- -> Record r
15- -> a
16- unsafeGet s = unsafePartial fromJust <<< S .lookup s <<< unsafeCoerce
17-
18- unsafeSet
19- :: forall r1 r2 a
20- . String
21- -> a
22- -> Record r1
23- -> Record r2
24- unsafeSet s a = unsafeCoerce <<< S .insert s a <<< unsafeCoerce
25-
26- get
27- :: forall r r' l a
28- . IsSymbol l
29- => RowCons l a r' r
30- => SProxy l
31- -> Record r
32- -> a
33- get l = unsafeGet (reflectSymbol l)
344
35- set
36- :: forall r1 r2 r l a b
37- . IsSymbol l
38- => RowCons l a r r1
39- => RowCons l b r r2
40- => SProxy l
41- -> b
42- -> Record r1
43- -> Record r2
44- set l = unsafeSet (reflectSymbol l)
5+ import Data.Lens (Lens , lens )
6+ import Data.Record (get , set )
7+ import Data.Symbol (class IsSymbol , SProxy )
458
469-- | Construct a (type-changing) lens for a record property, by providing a
4710-- | proxy for the `Symbol` which corresponds to the property label.
You can’t perform that action at this time.
0 commit comments