Skip to content

Add NoDataDeriving language extension

Fredrik Wieczerkowski requested to merge no-data-deriving into master

This branch adds the new language extension NoDataDeriving for disabling the implicit deriving of Prelude.Data instances. For example, the following program will no longer compile:

{-# LANGUAGE NoDataDeriving #-}

data X = A | B

data Y

requireData :: Data a => a
requireData = failed

main :: IO ()
main = do
  return (requireData :: X)
  return (requireData :: Y)
  return ()
Error:
    Missing instance for Prelude.Data X
    in explicitly typed expression
    requireData

Error:
    Missing instance for Prelude.Data Y
    in explicitly typed expression
    requireData

The idea behind making this a language extension (instead of e.g. a simple flag) is that is similar in spirit to NoImplicitPrelude and that it changes core language semantics. Additionally this opens up the possibility of having NoImplicitPrelude imply NoDataDeriving in the future.

Merge request reports

Loading