Ticket #2135 (new feature request)

Opened 5 years ago

Last modified 8 months ago

Warn if functions are exported whose types cannot be written

Reported by: dons Owned by:
Priority: lowest Milestone: 7.6.2
Component: Compiler Version: 6.8.2
Keywords: warnings Cc: dons@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

It should be possible to warn if a function is exported from a module whose type is hidden, and thus the function's type can't be written down directly by the user.

With the proliferation in type level programming in Haskell (and its use in libraries), situations can arise where functions are exported from a module which can be used, but whose type cannote be written, but where the type is complex enough that it really is required to write it down for the code to compile. This happened recently in the takusen library.

A warning for this situation would help authors of libraries avoid this situation.

Change History

Changed 5 years ago by igloo

  • difficulty set to Unknown

Type synonyms make this trickier, e.g.:

module Q (TypeSyn, v) where

v :: RealType
v = Val

type TypeSyn = RealType

data RealType = Val

Perhaps this warning should only be used for values which have explicit type signatures, and should warn if the types in the explicit type signature aren't exported?

I think we'd also have to ignore types that aren't defined in the current module, as we don't want to have to re-export all the types we use in our type signatures. But if we do that then we can be tripped up by modules hidden at the package level.

Changed 5 years ago by simonpj

An unambiguous (and easier-to-check) specification might be this:

  • Warn if a module M exports a function with an explicit type signature that mentions one or more type constructors that are defined in M but not exported.

If you want to check for explicit type signatures, there's a flag for that. (Albeit no flag to check for explicit type sigs on exports, but ignore non-exported functions. That would be another easy to add flag.)

Changed 5 years ago by igloo

  • milestone set to 6.10 branch

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple

Changed 4 years ago by igloo

  • milestone changed from 6.10 branch to 6.12 branch

Changed 3 years ago by igloo

  • milestone changed from 6.12 branch to 6.12.3

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 2 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 20 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 16 months ago by igloo

  • priority changed from low to lowest
  • milestone changed from 7.4.1 to 7.6.1

Changed 8 months ago by igloo

  • milestone changed from 7.6.1 to 7.6.2
Note: See TracTickets for help on using tickets.