Skip to content

[#671] Better type errors on invalid int casts

Description

Problem: Safe(r) fromIntegral (i.e. intCast) reports a confusing type error "Couldn't match type ‘'False’ with ‘'True’" on invalid conversion.

Solution: Introduce CheckIntSubType constraint synonym, equivalent to IsIntSubType a b ~ 'True, but reporting a human-readable TypeError when IsIntSubType a b ~ 'False.

Related issue(s)

Resolves #671 (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.
  • 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