bookkeeper 0.2.4 → 0.2.5
raw patch · 7 files changed
+91/−71 lines, 7 filesdep ~Globdep ~QuickCheckdep ~basenew-uploader
Dependency ranges changed: Glob, QuickCheck, base
Files
- README.md +5/−2
- bookkeeper.cabal +31/−27
- doctest/Doctest.hs +28/−0
- package.yaml +12/−11
- src/Bookkeeper/Internal.hs +8/−1
- src/Bookkeeper/Lens.hs +7/−2
- test/Doctest.hs +0/−28
README.md view
@@ -1,6 +1,6 @@-# Bookkeeper+# Bookkeeper [![Build Status][ci-img]][ci] -Bookkeeper is a new Haskell library that uses the new OverlodaedLabels feature+Bookkeeper is a new Haskell library that uses the new OverloadedLabels feature of GHC 8 to provide a new take on datatypes and records: ~~~ {.haskell}@@ -52,3 +52,6 @@ main :: IO () main = return () ~~~++[ci-img]: https://travis-ci.org/turingjump/bookkeeper.svg?branch=master+[ci]: https://travis-ci.org/turingjump/bookkeeper
bookkeeper.cabal view
@@ -1,11 +1,13 @@--- This file has been generated from package.yaml by hpack version 0.14.1.+-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack+--+-- hash: 919c9bd63ad7efe1c1c555270f3970af8bead66e26cb198aca395daf0d1abc13 name: bookkeeper-version: 0.2.4+version: 0.2.5 synopsis: Anonymous records and overloaded labels-description: Please see README.md+description: Please see README.md for more information and examples. category: Data Structures, Records homepage: http://github.com/turingjump/bookkeeper#readme bug-reports: https://github.com/turingjump/bookkeeper/issues@@ -14,7 +16,7 @@ copyright: (c) Julian K. Arni license: BSD3 license-file: LICENSE-tested-with: GHC == 8.0.1+tested-with: GHC == 8.0.1, GHC == 8.2.1 build-type: Simple cabal-version: >= 1.10 @@ -33,9 +35,9 @@ default-extensions: AutoDeriveTypeable ConstraintKinds DataKinds DefaultSignatures DeriveFunctor DeriveGeneric DeriveFoldable DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs MultiParamTypeClasses KindSignatures TypeInType OverloadedStrings RankNTypes ScopedTypeVariables TypeApplications TypeFamilies TypeOperators OverloadedLabels MagicHash ghc-options: -Wall build-depends:- base >= 4.9 && < 4.10- , type-level-sets+ base >=4.9 && <4.11 , data-default-class+ , type-level-sets exposed-modules: Bookkeeper Bookkeeper.Internal@@ -49,29 +51,29 @@ exec ghc-options: -Wall -pgmL markdown-unlit -fno-warn-unused-top-binds build-depends:- base >= 4.9 && < 4.10- , type-level-sets+ base >=4.9 && <4.11+ , bookkeeper , data-default-class- , base >=4.9 && < 4.10 , bookkeeper , markdown-unlit+ , markdown-unlit+ , type-level-sets default-language: Haskell2010 test-suite doctest type: exitcode-stdio-1.0 main-is: Doctest.hs hs-source-dirs:- test+ doctest default-extensions: AutoDeriveTypeable ConstraintKinds DataKinds DefaultSignatures DeriveFunctor DeriveGeneric DeriveFoldable DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs MultiParamTypeClasses KindSignatures TypeInType OverloadedStrings RankNTypes ScopedTypeVariables TypeApplications TypeFamilies TypeOperators OverloadedLabels MagicHash ghc-options: -Wall build-depends:- base >= 4.9 && < 4.10- , type-level-sets+ Glob >=0.7 && <0.9+ , base >=4.9 && <4.11 , data-default-class- , doctest >= 0.9 && < 0.12- , Glob >= 0.7 && < 0.8- , yaml == 0.8.*+ , doctest >=0.9 && <0.12+ , type-level-sets+ , yaml ==0.8.* other-modules:- BookkeeperSpec- Spec+ Paths_bookkeeper default-language: Haskell2010 test-suite spec@@ -82,15 +84,15 @@ default-extensions: AutoDeriveTypeable ConstraintKinds DataKinds DefaultSignatures DeriveFunctor DeriveGeneric DeriveFoldable DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs MultiParamTypeClasses KindSignatures TypeInType OverloadedStrings RankNTypes ScopedTypeVariables TypeApplications TypeFamilies TypeOperators OverloadedLabels MagicHash ghc-options: -Wall build-depends:- base >= 4.9 && < 4.10- , type-level-sets- , data-default-class+ QuickCheck >=2.8 && <2.11+ , base >=4.9 && <4.11 , bookkeeper- , hspec > 2 && < 3- , QuickCheck >= 2.8 && < 2.9+ , data-default-class+ , hspec >2 && <3+ , type-level-sets other-modules: BookkeeperSpec- Doctest+ Paths_bookkeeper default-language: Haskell2010 benchmark bench@@ -99,11 +101,13 @@ hs-source-dirs: bench default-extensions: AutoDeriveTypeable ConstraintKinds DataKinds DefaultSignatures DeriveFunctor DeriveGeneric DeriveFoldable DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs MultiParamTypeClasses KindSignatures TypeInType OverloadedStrings RankNTypes ScopedTypeVariables TypeApplications TypeFamilies TypeOperators OverloadedLabels MagicHash- ghc-options: -Wall -O2+ ghc-options: -Wall -Wall build-depends:- base >= 4.9 && < 4.10- , type-level-sets- , data-default-class+ base >=4.9 && <4.11 , bookkeeper , criterion+ , data-default-class+ , type-level-sets+ other-modules:+ Paths_bookkeeper default-language: Haskell2010
+ doctest/Doctest.hs view
@@ -0,0 +1,28 @@++module Main (main) where++-- Runs doctest on all files in "src" dir. Assumes:+-- (a) You are using hpack+-- (b) The library has a 'default-extensions' section++import System.FilePath.Glob (glob)+import Test.DocTest (doctest)+import Data.Yaml++newtype Exts = Exts { getExts :: [String] }+ deriving (Eq, Show, Read)++instance FromJSON Exts where+ parseJSON (Object v) = do+ lib <- v .: "library"+ Exts <$> lib .: "default-extensions"+ parseJSON _ = fail "expecting object"++main :: IO ()+main = do+ hpack' <- decodeFile "package.yaml"+ extensions <- case hpack' of+ Nothing -> return $ Exts mempty+ Just v -> return v+ files <- glob "src/**/*.hs"+ doctest $ files ++ fmap ("-X" ++) (getExts extensions)
package.yaml view
@@ -1,7 +1,7 @@ name: bookkeeper-version: 0.2.4+version: 0.2.5 synopsis: Anonymous records and overloaded labels-description: Please see README.md+description: Please see README.md for more information and examples. homepage: http://github.com/turingjump/bookkeeper#readme license: BSD3 license-file: LICENSE@@ -9,7 +9,7 @@ maintainer: jkarni@gmail.com copyright: (c) Julian K. Arni github: turingjump/bookkeeper-tested-with: GHC == 8.0.1+tested-with: GHC == 8.0.1, GHC == 8.2.1 category: Data Structures, Records extra-source-files: - CHANGELOG.md@@ -19,7 +19,7 @@ ghc-options: -Wall dependencies:- - base >= 4.9 && < 4.10+ - base >= 4.9 && < 4.11 - type-level-sets - data-default-class @@ -60,14 +60,14 @@ dependencies: - bookkeeper - hspec > 2 && < 3- - QuickCheck >= 2.8 && < 2.9+ - QuickCheck >= 2.8 && < 2.11 doctest: main: Doctest.hs- source-dirs: test+ source-dirs: doctest default-extensions: *allExts dependencies: - doctest >= 0.9 && < 0.12- - Glob >= 0.7 && < 0.8+ - Glob >= 0.7 && < 0.9 - yaml == 0.8.* benchmarks:@@ -78,7 +78,7 @@ dependencies: - bookkeeper - criterion- ghc-options: -O2+ ghc-options: -Wall executables:@@ -88,6 +88,7 @@ source-dirs: exec default-extensions: [] other-modules: []- dependencies: base >=4.9 && < 4.10- , bookkeeper- , markdown-unlit+ dependencies:+ - base >=4.9 && < 4.11+ - bookkeeper+ - markdown-unlit
src/Bookkeeper/Internal.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-redundant-constraints #-} module Bookkeeper.Internal where @@ -75,7 +76,11 @@ instance (s ~ s') => IsLabel s (Key s') where+#if MIN_VERSION_base(4,10,0)+ fromLabel = Key+#else fromLabel _ = Key+#endif -- | 'Key' is simply a proxy. You will usually not need to generate it -- directly, as it is generated by the OverlodadedLabels magic.@@ -238,7 +243,9 @@ instance (book ~ Expected (l :+: r)) => FromGeneric (l :+: r) book where fromGeneric = error "impossible" -instance (book ~ Expected U1) => FromGeneric U1 book where+instance {-# OVERLAPPABLE #-}+ (book ~ Expected lhs, lhs ~ U1+ ) => FromGeneric lhs book where fromGeneric = error "impossible"
src/Bookkeeper/Lens.hs view
@@ -1,10 +1,11 @@ {-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Bookkeeper.Lens where import GHC.OverloadedLabels import Bookkeeper.Internal-import GHC.TypeLits (Symbol, KnownSymbol, TypeError, ErrorMessage(..))+import GHC.TypeLits (Symbol) -- * Lenses @@ -36,5 +37,9 @@ s2ft ~ (Book' old -> f (Book' new))) => IsLabel (field :: Symbol) ((val -> f valnew) -> s2ft) where- fromLabel _ = rlens (Key @field)+#if MIN_VERSION_base(4,10,0)+ fromLabel = rlens (Key @field)+#else+ fromLabel _ = rlens (Key @field)+#endif
− test/Doctest.hs
@@ -1,28 +0,0 @@--module Main (main) where---- Runs doctest on all files in "src" dir. Assumes:--- (a) You are using hpack--- (b) The library has a 'default-extensions' section--import System.FilePath.Glob (glob)-import Test.DocTest (doctest)-import Data.Yaml--newtype Exts = Exts { getExts :: [String] }- deriving (Eq, Show, Read)--instance FromJSON Exts where- parseJSON (Object v) = do- lib <- v .: "library"- Exts <$> lib .: "default-extensions"- parseJSON _ = fail "expecting object"--main :: IO ()-main = do- hpack' <- decodeFile "package.yaml"- extensions <- case hpack' of- Nothing -> return $ Exts mempty- Just v -> return v- files <- glob "src/**/*.hs"- doctest $ files ++ fmap ("-X" ++) (getExts extensions)