purescript-record icon indicating copy to clipboard operation
purescript-record copied to clipboard

Thoughts on replacing Proxy with VTA?

Open pete-murphy opened this issue 2 years ago • 3 comments

Is there any interest in (or objection to) updating this library to use Visible Type Application syntax in place of Proxy?

pete-murphy avatar Jan 05 '24 02:01 pete-murphy

Hm, maybe Builder would still need Proxy unless I'm not seeing how to make this testBuilder compile

  let
    testBuilder =
      ( Builder.build
          :: forall r
           . Builder { | r } { x :: String, y :: String | r }
          -> { | r }
          -> { x :: String, y :: String | r }
      )
        ( Builder.insert @"x" 42
            >>> Builder.merge { y: true, z: "testing" }
            >>> Builder.delete @"y"
            >>> Builder.modify @"x" show
            >>> Builder.rename @"z" @"y"
        )
        {}

I thought adding the type annotation to build might be the best I could do to help infer the right constraints, but I get the following error on the call to Builder.insert @"x"

  An expression of polymorphic type
  with the invisible type variable l:

    forall l a r1 r2. Cons l a r1 r2 => Lacks l r1 => IsSymbol l => a -> Builder (Record r1) (Record r2)

  cannot be applied to:

    "x"

pete-murphy avatar Jan 05 '24 04:01 pete-murphy

Hm, maybe Builder would still need Proxy unless I'm not seeing how to make this testBuilder compile

Oops, nevermind, I had forgot to make some of the type variables visible with @ (which is what the error is saying).

pete-murphy avatar Jan 05 '24 12:01 pete-murphy

There's a current/active thread on the forum discussing the guidelines we're going to use for updating libraries with VTAs, might be worth chiming in there too: https://discourse.purescript.org/t/proposal-guidelines-for-vtas/3866

garyb avatar Jan 05 '24 14:01 garyb