driving-classes-plugin: Deriving without spelling out "deriving"

[ development, library, mit ] [ Propose Tags ]

This plugin implicitly adds "deriving" clauses to all data types in a module. See Driving.Classes to get started.


[Skip to Readme]
Versions [RSS] [faq] 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.1.3.0
Change log CHANGELOG.md
Dependencies base (>=4.12 && <4.17), containers, ghc [details]
License MIT
Copyright 2021 Li-yao Xia
Author Li-yao Xia
Maintainer lysxia@gmail.com
Category Development
Bug tracker https://gitlab.com/Lysxia/driving-classes-plugin
Uploaded by lyxia at 2021-11-13T20:45:12Z
Distributions NixOS:0.1.2.0
Downloads 171 total (66 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2021-11-13 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates


Readme for driving-classes-plugin-0.1.3.0

[back to package description]

Deriving without spelling out "deriving"

This GHC plugin automatically adds deriving clauses to all data types in a module.

Examples

The following module uses this plugin to derive Eq, Ord, Show for all types by default, excluding invalid instances with the NoDriving option.

{-# LANGUAGE DerivingStrategies #-}
{-# OPTIONS_GHC -fplugin=Driving.Classes #-}

module X where

{-# ANN module (Driving :: Driving
  '[ Stock '(Eq, Ord, Show)
   , NoDriving '(Eq MyEndo, Ord MyEndo, Show MyEndo)
   ]) #-}

data T = C1 | C2
data U = D1 | D2
data V = E1 | E2

newtype MyEndo a = MyEndo (a -> a)

Deriving Functor and Applicative via WrappedMonad:

{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving, DerivingVia #-}
{-# OPTIONS_GHC -fplugin=Driving.Classes #-}

module X where

import Control.Applicative (WrappedMonad(..))

{-# ANN module (Driving :: Driving
  '[ '(Functor, Applicative) `ViaF` WrappedMonad
   , Newtype Monad
   ]) #-}

newtype A a = A [a]
newtype B a = B (IO a)
newtype C a = C (Maybe a)