LANGUAGE pragma synonyms
Here are the first 20 lines of a typical Haskell file of mine:
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE LiberalTypeSynonyms #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE AutoDeriveTypeable #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE OverlappingInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ConstraintKinds #-}
Over a couple of modules in a small package, I find myself copy-pasting these 20 lines, as either I will use these extensions, or they won't really cause any harm to the code I'm writing.
As a way to simplify this, and reduce code duplication, I propose introducing LANGUAGE pragma synonyms:
{-# LANGUAGE PedrosHaskell = EmptyDataDecls, FlexibleContexts, FlexibleInstances
, LiberalTypeSynonyms, ScopedTypeVariables
, RankNTypes, StandaloneDeriving, AutoDeriveTypeable
, DeriveDataTypeable, DeriveGeneric, DefaultSignatures
, OverlappingInstances, UndecidableInstances
, MultiParamTypeClasses, TypeOperators, TypeFamilies
, GADTs, DataKinds, PolyKinds, ConstraintKinds #-}
After writing this, in that same module or any module that imports it, I could just write:
{-# LANGUAGE PedrosHaskell #-}
And all the pragmas above would be enabled.
Besides making my life easier, I suspect this will also help increase modularity of certain packages. For example, packages could define a package-specific language pragma that should be enabled in order to use that package. Then, if the package maintainer upgrades one datatype to become a GADT, the pragma would be updated to include GADTs
, and user code (that could now be requiring that pragma) would automatically enable GADTs
too.
Furthermore, it can also make the language standardisation process simpler. After all,
{-# LANGUAGE Haskell2010 = PatternGuards, NoNPlusKPatterns, RelaxedPolyRec
, EmptyDataDecls, ForeignFunctionInterface #-}
Trac metadata
Trac field | Value |
---|---|
Version | 7.9 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |