Skip to content

Allow signatures without a binding

In other words so I can write

someFancyFunction :: a -> (forall b. b -> c) -> (a -> b) -> c

currently GHC errors

Top.hs:3:1: error:
    The type signature for ‘someFancyFunction’
      lacks an accompanying binding
  |
3 | someFancyFunction :: a -> (forall b. b -> c) -> (a -> b) -> c
  | ^^

Though one can simulate the behavior by compiling with -fdefer-type-errors and supplying some non-sense implementation:

someFancyFunction :: a -> (forall b. b -> c) -> (a -> b) -> c
someFancyFunction = ()

An alternative is to write

someFancyFunction :: a -> (forall b. b -> c) -> (a -> b) -> c
someFancyFunction x y z = someFancyFunction x y z

or

someFancyFunction _x _y _z = undefined -- need to eta-expand because of rankN argument

But both of these are not great option: it's very easy to leave the "temporary" placeholders into the code base. GHC cannot help to find them. (it can with -fdefer-type-errors trick, but that feels roundabout - and does "too much" on the side).

I argue that very similar functionality already exists in GHC: missing type class members and missing record fields are filled by GHC. These issue warnings which can be turned into errors. Missing binding for a signature could also be a warning, which is an error by default. Or it could be a -f.. flag.

I think it will be very useful for interactive development, so GHC don't error too early.

Edited by Oleg Grenrus
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information