Define set that prevents change of type

Hello,

I’m looking throught Record module and I like get, set, modify, etc functions, but I would like to know how would you define function set that would not by able to change type of label on record? I’m experimenting with using set and more restrictive typespec…

a_ = SProxy :: SProxy "a"

mset :: forall r l a. IsSymbol l => SProxy l -> a -> Record r -> Record r
mset = set

main :: Effect Unit
main = logShow $ mset a_ "String" { a : 1 }

If you look at the signature of set:

set
  :: forall r1 r2 r l a b
   . IsSymbol l
  => Cons l a r r1
  => Cons l b r r2
  => SProxy l
  -> b
  -> Record r1
  -> Record r2

You can take out everything mentioning b

mset
  :: forall r1 r l a
   . IsSymbol l
  => Cons l a r r1
  => SProxy l
  -> a
  -> Record r1
  -> Record r1
mset = set
1 Like

Thank you I actualy forget to update main and was thinking something else is wrong :man_facepalming:

1 Like