Skip to content

Deriving Enum leads to weird hlint warnings in generated code #1456

@dschrempf

Description

@dschrempf

I know this is a bit of pain point, but our generated bindings lead to hlint warnings using default settings (HLS with hlint enabled, no ohter customizations).

Warnings:

 ✲ Name:        Partial: ghc-internal/toEnum
 ✲ Description: Usage of partial function 'toEnum' for enumerable types
 ✲ Severity:    Warning
 ✲ Category:    #Partial
Possible solutions:
  - {Extra dependency} Use 'safeToEnum' from 'Relude.Extra.Enum' in 'relude'

 ✲ Name:        Partial: ghc-internal/pred
 ✲ Description: Usage of partial function 'pred' for enumerable types
 ✲ Severity:    Warning
 ✲ Category:    #Partial
Possible solutions:
  - Use '(- 1)' for integral types (but be aware of arithmetic overflow)
  - {Extra dependency} Use 'prev' from 'Relude.Extra.Enum' in 'relude'

 ✲ Name:        Partial: ghc-internal/succ
 ✲ Description: Usage of partial function 'succ' for enumerable types
 ✲ Severity:    Warning
 ✲ Category:    #Partial
Possible solutions:
  - Use '(+ 1)' for integral types (but be aware of arithmetic overflow)
  - {Extra dependency} Use 'next' from 'Relude.Extra.Enum' in 'relude'

This is particularly annoying in TH mode, when the complete splice is underlined:

Image

Should we just accept this, or add an hlint exception to the file? (Or not derive Enum)?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions