Skip to content

[#623] Make it difficult to misuse 'Show'

Nikolay Yakimov requested to merge lierdakil/#623-dont-misuse-show into master

Description

Not updating changelog yet, want some feedback.

Problem: It's not good to use 'show' instead of 'build'. That may happen for different reasons, but one of the common ones is that 'show' seems misleadingly appealing.

Solution: Make it harder to use 'show' by limiting the types it can be applied to with an open type family 'PrettyShow'. Export unconstrained 'show' variant from "Debug" module. Update our code base to use 'pretty' preferentially. If pretty is not available, use 'Debug.show' for now.

Design notes: 'PrettyShow a' has kind 'Constraint' because we occasionally want to constrain the 'show' instance, e.g. 'PrettyShow (Fixed a) = HasResolution a'. For types that are always pretty, we can use empty list of constraints '()'

Related issue(s)

Resolves #623 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)
    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.

Technically all our code base is a one giant test for this 😅

  • Documentation
    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Nikolay Yakimov

Merge request reports