Why not allow empty record updates?

Herbert Valerio Riedel hvr at gnu.org
Mon Nov 14 15:30:34 CET 2011

Hello GHC HQ,

I have been toying with phantom types in combination with "polymorphic"
record-updates (which is a great feature imho), but stumbled over a
limitation: GHC doesn't allow empty record updates (see toy example
below), and I couldn't find a GHC language extension to relax this
constraint. In the toy-example below it was easy to workaround by
performing a dummy record update, but for more advanced uses workarounds
becomes a bit more annoying.

Is there a particular reason why empty record updates are disallowed by
the Haskell Report? Would it be sensible, to allow empty record updates
as a GHC language extension?


-- empty types for tagging
data Clean
data Dirty

data Foo a = Foo { fa :: Int, fb :: String }
data Bar a = Bar { ba :: Int, bb :: Foo a }

markDirtyFoo :: Foo Clean -> Foo Dirty
markDirtyFoo foo = foo { } -- rejected with "Empty record update" error
markDirtyFoo foo = foo { fa = fa foo } -- workaround: dummy update

markDirtyBar :: Bar Clean -> Bar Dirty
markDirtyBar bar = bar { bb = markDirtyFoo (bb bar) } -- works

More information about the Glasgow-haskell-users mailing list