packages feed

generic-constraints 1.1.1 → 1.1.1.1

raw patch · 4 files changed

+124/−42 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

CHANGELOG view
@@ -1,5 +1,8 @@ CHANGELOG +1.1.1.1+  - Documentation+ 1.1.1   - Added TH to generate standalone deriving clauses 
+ README.md view
@@ -0,0 +1,31 @@+# Standalone deriving without boiler-plate++Write short and concise contexts based on generics.++Instead of writing boiler-plate standalone deriving clauses in the form of++```Haskell+deriving instance [Various Eq Constraints Here] => Instance Eq MyType+```++With generic-constraints you can use++```Haskell+deriving instance Constraints MyType Eq => Eq MyType+```++Or, using TH, simply++```Haskell+makeDeriving ''Eq ''MyType+```++And for several classes and types:++```Haskell+makeDerivings [''Eq, ''Ord, ''Show] [''MyType, ''MyOtherType]+```++## Credits++This library was extracted from the [one-liner](http://hackage.haskell.org/package/one-liner) library by Sjoerd Visscher and Xia Li-yao.
generic-constraints.cabal view
@@ -1,50 +1,56 @@-Name:                 generic-constraints-Version:              1.1.1-Synopsis:             Constraints via Generic-Description:          Write short and concise contexts based on generics-Homepage:             https://github.com/yairchu/generic-constraints-Bug-reports:          https://github.com/yairchu/generic-constraints/issues-License:              BSD3-License-file:         LICENSE-Author:               Sjoerd Visscher, Xia Li-yao, Yair Chuchem-Maintainer:           yairchu@gmail.com-Category:             Generics-Build-type:           Simple-Cabal-version:        >= 1.8--Extra-Source-Files:-  CHANGELOG--Library-  HS-Source-Dirs:  src--  Exposed-modules:-    Generics.Constraints+cabal-version: 1.12 -  Build-depends:-      base          >= 4.9 && < 5-    , template-haskell-    , th-abstraction+-- This file has been generated from package.yaml by hpack version 0.31.1.+--+-- see: https://github.com/sol/hpack+--+-- hash: 391f68f7468a0fe4836d47fadbe4b6da09284a187d90542ff3d753101d63f1be -  ghc-options:-    -Wall-    -Wnoncanonical-monad-instances-    -Wcompat-    -Wincomplete-record-updates-    -Wincomplete-uni-patterns-    -Wredundant-constraints+name:           generic-constraints+version:        1.1.1.1+synopsis:       Constraints via Generic+description:    Standalone deriving without boiler-plate+category:       Generics+homepage:       https://github.com/yairchu/generic-constraints+bug-reports:    https://github.com/yairchu/generic-constraints/issues+author:         Sjoerd Visscher,+                Xia Li-yao,+                Yair Chuchem+maintainer:     yairchu@gmail.com+license:        BSD3+license-file:   LICENSE+build-type:     Simple+extra-source-files:+    README.md+    CHANGELOG  source-repository head-  type:     git+  type: git   location: git://github.com/yairchu/generic-constraints.git -Test-suite unittests-  Hs-source-dirs:  test-  Main-is:         unittests.hs+library+  exposed-modules:+      Generics.Constraints+  other-modules:+      Paths_generic_constraints+  hs-source-dirs:+      src+  ghc-options: -Wall -Wnoncanonical-monad-instances -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints+  build-depends:+      base >=4.9 && <5+    , template-haskell+    , th-abstraction+  default-language: Haskell2010 -  Build-depends:-      base-    , HUnit+test-suite unittests+  type: exitcode-stdio-1.0+  main-is: unittests.hs+  other-modules:+      Paths_generic_constraints+  hs-source-dirs:+      test+  build-depends:+      HUnit+    , base     , generic-constraints--  Type: exitcode-stdio-1.0+  default-language: Haskell2010
src/Generics/Constraints.hs view
@@ -1,3 +1,16 @@+-- | Write short and concise contexts based on generics.+--+-- Instead of writing boiler-plate standalone deriving clauses in the form of+--+-- > deriving instance [Various Eq Constraints Here] => Instance Eq MyType+--+-- You can use+--+-- > deriving instance Constraints MyType Eq => Eq MyType+--+-- And with the `TemplateHaskell` helpers @makeDeriving@ and others,+-- your declarations can be even more concise.+ {-# LANGUAGE     PolyKinds   , TypeFamilies@@ -7,6 +20,7 @@   #-} module Generics.Constraints     ( Constraints+      -- | Template Haskell helpers     , makeDeriving, makeDerivings     , makeInstance, makeInstances     ) where@@ -30,20 +44,48 @@ -- | `Constraints` is a constraint type synonym, containing the constraint -- requirements for an instance for `t` of class `c`. -- It requires an instance of class `c` for each component of `t`.+--+-- Useful for the writing the context of `StandaloneDeriving` clauses:+--+-- > deriving instance Constraints MyType Eq => Eq MyType type Constraints t c = Constraints' (Rep t) c +-- | `TemplateHaskell` generation of multiple standalone deriving declarations.+--+-- > makeDerivings [''Eq, ''Ord, ''Show] [''MyType, ''MyOtherType]+--+-- Generates the deriving declarations for all given classes and types. makeDerivings :: [T.Name] -> [T.Name] -> T.DecsQ makeDerivings = makeMany makeDeriving +-- | `TemplateHaskell` generation of multiple instance declarations.+--+-- > makeInstances [''Binary, ''NFData] [''MyType, ''MyOtherType]+--+-- Generates the instances declarations for all given classes and types. makeInstances :: [T.Name] -> [T.Name] -> T.DecsQ makeInstances = makeMany makeInstance  makeMany :: (T.Name -> T.Name -> T.DecsQ) -> [T.Name] -> [T.Name] -> T.DecsQ makeMany f classes types = concat <$> sequence (f <$> classes <*> types) +-- | `TemplateHaskell` generation of a standalone deriving declaration.+--+-- > makeDeriving ''Ord ''MyType+--+-- Generates:+--+-- > deriving instance Constraints MyType Ord => Ord MyType makeDeriving :: T.Name -> T.Name -> T.DecsQ makeDeriving = makeCommon (T.StandaloneDerivD Nothing) +-- | `TemplateHaskell` generation of an instance declaration with no methods.+--+-- > makeDeriving ''Binary ''MyType+--+-- Generates:+--+-- > instance Constraints MyType Binary => Binary MyType makeInstance :: T.Name -> T.Name -> T.DecsQ makeInstance = makeCommon (\c i -> T.InstanceD Nothing c i [])