Skip to content

Can't use NamedFieldPuns and ScopedTypeVariables together

Motivation

I believe there is a "hole" in interactions between NamedFieldPuns and ScopedTypeVariables.

{-# LANGUAGE NamedFieldPuns, ScopedTypeVariables #-}

data X a = X {field :: Y a}

data Y a

f :: X a -> ...
f X {field :: Y a} = ...

This is currently not a valid way (doesn't parse) to bind type variables.

Proposal

I propose that

f X {field :: Y a} = ...

desugar(?) to

f X {field = field :: Y a} = ...
Edited by Georgi Lyubenov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information