purescript / purescript-record

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

Add nubbed merge #43

Closed natefaubion closed 6 years ago

natefaubion commented 6 years ago

This does what #40 does but with new compiler stuff. I did not make the change for a mutating Builder merge, as I think that might warrant some more discussion.

MonoidMusician commented 6 years ago

Thanks Nate, looks good to me! Do you want to add the version of merge that ensures they are disjoint (and has better inference)?

-- | Merge two disjoint records (containing different labels). This helps infer
-- | types for the input records based on the output records, as `merge` only
-- | will infer the output based upon the input.
-- |
-- | For example, hole `?help` is inferred to have type ``{ b :: Int }` here:
-- |
-- | ```purescript
-- | merge' { a: 5 } ?help :: { a :: Int, b :: Int }
-- | ```
merge'
  :: forall r1 r2 r3
   . Union r1 r2 r3
  => Nub r3 r3
  => Record r1
  -> Record r2
  -> Record r3
merge' l r = merge l r
natefaubion commented 6 years ago

I've added disjointUnion.

MonoidMusician commented 6 years ago

Thanks! you win the naming game :trophy: :smile: