Skip to content

Conversation

@JordanMartinez
Copy link
Contributor

@JordanMartinez JordanMartinez commented Sep 19, 2021

Description of the change

Fixes #216. I'm not sure if this would be considered breaking or not.


Checklist:

  • Added the change to the changelog's "Unreleased" section with a reference to this PR (e.g. "- Made a change (#0000)")
  • Linked any existing issues or proposals that this pull request should close
  • Updated or added relevant documentation
  • Added a test for the contribution (if applicable)

@JordanMartinez
Copy link
Contributor Author

Looks like this can't be fixed. CI fails with:


[1/1 NoInstanceFound] src/Data/Show.purs:50:22

  50    show record = case showRecordFields (Proxy :: Proxy ls) record of
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  
  No type class instance was found for
  
    Data.Show.ShowRecordFields ls3
                               rs4
  
  while applying a function showRecordFields
    of type ShowRecordFields t0 t1 => t2 t0 -> Record t1 -> Array String
    to argument Proxy
  while inferring the type of showRecordFields Proxy
  in value declaration showRecord
  
  where ls3 is a rigid type variable
          bound at (line 0, column 0 - line 0, column 0)
        rs4 is a rigid type variable
          bound at (line 0, column 0 - line 0, column 0)
        t1 is an unknown type
        t0 is an unknown type
        t2 is an unknown type

           Src   Lib   All
Warnings   0     0     0  
Errors     1     0     1  

@hdgarrood
Copy link
Contributor

I think saying "this can't be fixed" is a bit premature. It looks to me like you're (correctly) asking for a Nub constraint as well as the an ShowRecordFields instance for rs' in the Show instance context, but in the actual implementation you're still asking for a ShowRecordFields instance for rs, which you now don't have.

@JordanMartinez
Copy link
Contributor Author

Ah... That explains the type error.

@JordanMartinez
Copy link
Contributor Author

I added a second Nub constraint, but thinking about this more, couldn't we also wrote Union () rs' rs?

@JordanMartinez JordanMartinez added the type: breaking change A change that requires a major version bump. label Nov 20, 2021
@JordanMartinez JordanMartinez added the purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 label Dec 4, 2021
@JordanMartinez
Copy link
Contributor Author

🏓 @thomashoneyman

@thomashoneyman
Copy link
Member

thomashoneyman commented Mar 16, 2022

This one's a bit out of my wheelhouse — perhaps @hdgarrood could take another look?

Comment on lines 46 to 47
( Nub rs rs'
, Nub rs' rs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be asserted with Nub rs rs?

Copy link
Contributor

@hdgarrood hdgarrood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. I think this is breaking - if you are using show on a record whose type isn't concrete, then you might not have a Nub rs rs instance in scope and presumably your code would break. For example, if for some reason you wrote

myShowRecord :: forall rs ls. (RL.RowToList rs ls, ShowRecordFields ls rs) => Record rs -> String
myShowRecord = show

then I think that would break after this change.

@JordanMartinez
Copy link
Contributor Author

So...

  1. Should I update the Changelog file to remove the bugfix entry?
  2. Should I mention Harry's comment as description in the breaking change entry?

@hdgarrood
Copy link
Contributor

I think removing the bugfix entry from changelog makes sense, but I'd say my previous comment is more detail than is appropriate for the changelog.

@JordanMartinez JordanMartinez merged commit eff3517 into master Mar 16, 2022
@JordanMartinez JordanMartinez deleted the fix-Show-record-instance branch March 16, 2022 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 type: breaking change A change that requires a major version bump.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record instances using unsafe functions break in the presence of duplicate labels.

5 participants