Opened 10 years ago

Last modified 23 months ago

#2135 new feature request

Warn if functions are exported whose types cannot be written

Reported by: dons Owned by:
Priority: lowest Milestone:
Component: Compiler Version: 6.8.2
Keywords: warnings Cc: dons@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

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 (19)

comment:1 Changed 10 years ago by igloo

difficulty: 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.

comment:2 Changed 10 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.)

comment:3 Changed 10 years ago by igloo

Milestone: 6.10 branch

comment:4 Changed 9 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:5 Changed 9 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:6 Changed 9 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:7 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:8 Changed 8 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:9 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:10 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:11 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:12 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:13 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:14 Changed 3 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:15 Changed 3 years ago by thoughtpolice

Milestone: 7.10.17.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:16 Changed 3 years ago by thoughtpolice

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:17 Changed 2 years ago by thoughtpolice

Milestone: 7.12.18.0.1

Milestone renamed

comment:18 Changed 23 months ago by thomie

Type of failure: Incorrect warning at compile-time

comment:19 Changed 23 months ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.