purescript / purescript-record

Functions for working with records and polymorphic labels
BSD 3-Clause "New" or "Revised" License
70 stars 31 forks source link

Thoughts on replacing Proxy with VTA? #85

Open pete-murphy opened 9 months ago

pete-murphy commented 9 months ago

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

pete-murphy commented 9 months ago

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 commented 9 months ago

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).

garyb commented 9 months ago

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