packages feed

sum-type-boilerplate 0.1.0 → 0.1.1

raw patch · 4 files changed

+30/−42 lines, 4 filesdep +sum-type-boilerplatedep −HUnitdep −hlintPVP ok

version bump matches the API change (PVP)

Dependencies added: sum-type-boilerplate

Dependencies removed: HUnit, hlint

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -1,5 +1,9 @@ # sum-type-boilerplate Changelog +## 0.1.1++* Add GHC 8.2.1 compatibility+ ## 0.1.0  * Initial release. Includes a TH function to create a sum type and two TH
README.md view
@@ -2,10 +2,10 @@  [![CircleCI](https://circleci.com/gh/jdreaver/sum-type-boilerplate.svg?style=svg)](https://circleci.com/gh/jdreaver/sum-type-boilerplate) -This library allows users to use Template Haskell to easily construct and-manipulate sum types. It was born out of the author's desire to reduce the-boilerplate associated with sum types while keeping the type safety they-provide.+This library allows users to easily construct and manipulate sum types via+Template Haskell It was born out of the author's desire to reduce the+boilerplate associated with lots of large sum types while keeping the type+safety they provide.  ## Sum Types @@ -66,3 +66,23 @@ * The template haskell used here just produces vanilla Haskell data types. No   crazy type-level magic is going on. That means if you want to ditch this   library later on, just copy the generated code into your project.++## Motivation++While working on+my [event sourcing library](https://github.com/jdreaver/eventful) I found it is+super common for me to have to construct fairly large sum types of events. In+the system I was working on, each event handler has their own event sum type+that represents what events that handler can listen to. I also had a sum type+that holds all the events in the system for the purpose of serialization and+interacting with the database.++Converting between all of these event types became a huge pain, and I was+writing a ton of boilerplate. I didn't want to lose type safety or+encapsulation by just using the "big sum type" everywhere, but I also didn't+want to keep writing new sum types and conversion functions. Thus, I created+the Template Haskell functions that are now in `sum-type-boilerplate` to ease+the burden of writing this mechanical code.++I thought this might be useful not only for users of `eventful`, but also for+anyone that needs to deal with large sum types.
sum-type-boilerplate.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack  name:           sum-type-boilerplate-version:        0.1.0+version:        0.1.1 synopsis:       Library for reducing the boilerplate involved with sum types description:    Library for reducing the boilerplate involved in creating and manipulating sum types category:       Types,TH@@ -41,30 +41,12 @@   main-is: Spec.hs   hs-source-dirs:       tests-      library   ghc-options: -Wall   build-depends:       base >= 4.9 && < 5     , template-haskell     , hspec-    , HUnit-  other-modules:-      HLint-      SumTypes.THSpec-      SumTypes.TH-  default-language: Haskell2010--test-suite style-  type: exitcode-stdio-1.0-  main-is: HLint.hs-  hs-source-dirs:-      tests-  ghc-options: -Wall-  build-depends:-      base >= 4.9 && < 5-    , template-haskell-    , hlint+    , sum-type-boilerplate   other-modules:-      Spec       SumTypes.THSpec   default-language: Haskell2010
− tests/HLint.hs
@@ -1,18 +0,0 @@-module Main (main) where--import Language.Haskell.HLint (hlint)-import System.Exit (exitFailure, exitSuccess)--import Prelude (String, IO, null)--arguments :: [String]-arguments =-  [ "library"-  , "tests"-  , "-i=Redundant do"-  ]--main :: IO ()-main = do-  hints <- hlint arguments-  if null hints then exitSuccess else exitFailure