purescript-contrib/purescript-uint

UInt hidden constructors warning

Closed this issue · 6 comments

Warning:

  in module Data.UInt
  at src/Data/UInt.purs:5:1 - 316:42 (line 5, column 1 - line 316, column 42)

    An export for UInt hides data constructors but the type declares an instance of Data.Generic.Rep.Generic.
    Such instance allows to match and construct values of this type, effectively making the constructors public.


  See https://github.com/purescript/documentation/blob/master/errors/HiddenConstructors.md for more information,
  or to contribute content related to this warning.

Actually UInt has no constructors at all.

foreign import data UInt :: Type

We definitely want the Generic instance. So I'm not sure what to do about this. I'd like to get rid of this warning somehow.

Maybe instead of

foreign import data UInt :: Type

the definition for UInt should be

newtype UInt = UInt Int
derive instance newtypeUInt :: NewType UInt _

Would that be equivalent? Then we could export the constructor.

Here's a commit with an exported constructor newtype UInt = UInt Number which solves the problem of hidden constructor with Generic instance.

I don't love this and I'm open to suggestions.

6a54468

Done in v6.0.1