From edb3932efbb1e26ce063631d90d0851878f2b097 Mon Sep 17 00:00:00 2001 From: John Ky Date: Mon, 25 Nov 2019 11:56:16 +1100 Subject: [PATCH] Add NFData instances --- app/App/Commands/Count.hs | 5 +++-- cabal.project.local | 6 ------ hie.yaml | 12 ------------ hw-xml.cabal | 3 ++- project.sh | 5 +++-- src/HaskellWorks/Data/Xml/DecodeError.hs | 6 +++++- src/HaskellWorks/Data/Xml/Index.hs | 6 +++++- .../Data/Xml/Succinct/Cursor/BalancedParens.hs | 16 ++++++++++------ .../Data/Xml/Succinct/Cursor/BlankedXml.hs | 6 ++++-- .../Data/Xml/Succinct/Cursor/InterestBits.hs | 14 +++++++++----- 10 files changed, 41 insertions(+), 38 deletions(-) delete mode 100644 cabal.project.local delete mode 100644 hie.yaml diff --git a/app/App/Commands/Count.hs b/app/App/Commands/Count.hs index 61c94c2..af45e55 100644 --- a/app/App/Commands/Count.hs +++ b/app/App/Commands/Count.hs @@ -17,6 +17,7 @@ import Control.Monad import Data.Generics.Product.Any import Data.Semigroup ((<>)) import Data.Text (Text) +import GHC.Generics import HaskellWorks.Data.TreeCursor import HaskellWorks.Data.Xml.DecodeResult import HaskellWorks.Data.Xml.RawDecode @@ -40,11 +41,11 @@ import qualified System.IO as IO data Plant = Plant { common :: String , price :: String - } deriving (Eq, Show) + } deriving (Eq, Show, Generic) newtype Catalog = Catalog { plants :: [Plant] - } deriving (Eq, Show) + } deriving (Eq, Show, Generic) tags :: Value -> String -> [Value] tags xml@(XmlElement n _ _) elemName = if n == elemName diff --git a/cabal.project.local b/cabal.project.local deleted file mode 100644 index 55d7e95..0000000 --- a/cabal.project.local +++ /dev/null @@ -1,6 +0,0 @@ - -package * - ghc-location: ghc - -program-locations - ghc-location: ghc diff --git a/hie.yaml b/hie.yaml deleted file mode 100644 index f010534..0000000 --- a/hie.yaml +++ /dev/null @@ -1,12 +0,0 @@ -cradle: - direct: - arguments: - - -Wincomplete-patterns - - -Wincomplete-record-updates - - -Wincomplete-uni-patterns - - -Wname-shadowing - - -Worphans - - -Wredundant-constraints - - -Wunused-binds - - -Wunused-imports - - -Wunused-matches diff --git a/hw-xml.cabal b/hw-xml.cabal index 8b15db6..967e14f 100644 --- a/hw-xml.cabal +++ b/hw-xml.cabal @@ -38,7 +38,7 @@ common ghc-prim { build-depends: ghc-prim >= common hedgehog { build-depends: hedgehog >= 1.0 && < 1.1 } common hspec { build-depends: hspec >= 2.5 && < 3.0 } common hw-balancedparens { build-depends: hw-balancedparens >= 0.3.0.1 && < 0.4 } -common hw-bits { build-depends: hw-bits >= 0.7.0.7 && < 0.8 } +common hw-bits { build-depends: hw-bits >= 0.7.0.9 && < 0.8 } common hw-hspec-hedgehog { build-depends: hw-hspec-hedgehog >= 0.1 && < 0.2 } common hw-parser { build-depends: hw-parser >= 0.1.0.1 && < 0.2 } common hw-prim { build-depends: hw-prim >= 0.6.2.39 && < 0.7 } @@ -128,6 +128,7 @@ executable hw-xml import: base, config , attoparsec , bytestring + , deepseq , generic-lens , hw-balancedparens , hw-bits diff --git a/project.sh b/project.sh index 5faf3d6..25c2b31 100755 --- a/project.sh +++ b/project.sh @@ -17,7 +17,7 @@ case "$cmd" in build) cabal new-build all -j8 \ - --enable-tests --enable-benchmarks \ + --enable-tests --enable-benchmarks --write-ghc-environment-files=always \ $CABAL_FLAGS "$@" ;; @@ -26,7 +26,8 @@ case "$cmd" in ;; test) - cabal new-test -j8 --enable-tests --disable-documentation --test-show-details=direct \ + cabal v2-test -j8 --enable-tests --enable-benchmarks \ + --write-ghc-environment-files=always --test-show-details=direct \ $CABAL_FLAGS "$@" ;; diff --git a/src/HaskellWorks/Data/Xml/DecodeError.hs b/src/HaskellWorks/Data/Xml/DecodeError.hs index 5dac11b..70f33eb 100644 --- a/src/HaskellWorks/Data/Xml/DecodeError.hs +++ b/src/HaskellWorks/Data/Xml/DecodeError.hs @@ -1,5 +1,9 @@ +{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module HaskellWorks.Data.Xml.DecodeError where -newtype DecodeError = DecodeError String deriving (Eq, Show) +import Control.DeepSeq +import GHC.Generics + +newtype DecodeError = DecodeError String deriving (Eq, Show, Generic, NFData) diff --git a/src/HaskellWorks/Data/Xml/Index.hs b/src/HaskellWorks/Data/Xml/Index.hs index 559d8b3..efe0c14 100644 --- a/src/HaskellWorks/Data/Xml/Index.hs +++ b/src/HaskellWorks/Data/Xml/Index.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleInstances #-} module HaskellWorks.Data.Xml.Index @@ -5,8 +7,10 @@ module HaskellWorks.Data.Xml.Index , indexVersion ) where +import Control.DeepSeq import Data.Serialize import Data.Word +import GHC.Generics import HaskellWorks.Data.Bits.BitShown import qualified Data.Vector.Storable as DVS @@ -18,7 +22,7 @@ data Index = Index { xiVersion :: String , xiInterests :: BitShown (DVS.Vector Word64) , xiBalancedParens :: BitShown (DVS.Vector Word64) - } deriving (Eq, Show) + } deriving (Eq, Show, Generic, NFData) putBitShownVector :: Putter (BitShown (DVS.Vector Word64)) putBitShownVector = putVector . bitShown diff --git a/src/HaskellWorks/Data/Xml/Succinct/Cursor/BalancedParens.hs b/src/HaskellWorks/Data/Xml/Succinct/Cursor/BalancedParens.hs index 1e3cbd9..72dffbe 100644 --- a/src/HaskellWorks/Data/Xml/Succinct/Cursor/BalancedParens.hs +++ b/src/HaskellWorks/Data/Xml/Succinct/Cursor/BalancedParens.hs @@ -1,7 +1,9 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE InstanceSigs #-} -{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE InstanceSigs #-} +{-# LANGUAGE MultiParamTypeClasses #-} module HaskellWorks.Data.Xml.Succinct.Cursor.BalancedParens ( XmlBalancedParens(..) @@ -9,8 +11,10 @@ module HaskellWorks.Data.Xml.Succinct.Cursor.BalancedParens ) where import Control.Applicative +import Control.DeepSeq import Data.Word -import HaskellWorks.Data.BalancedParens as BP +import GHC.Generics +import HaskellWorks.Data.BalancedParens import HaskellWorks.Data.Xml.Internal.BalancedParens import HaskellWorks.Data.Xml.Internal.List import HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml @@ -18,7 +22,7 @@ import HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml import qualified Data.ByteString as BS import qualified Data.Vector.Storable as DVS -newtype XmlBalancedParens a = XmlBalancedParens a +newtype XmlBalancedParens a = XmlBalancedParens a deriving (Eq, Show, Generic, NFData) getXmlBalancedParens :: XmlBalancedParens a -> a getXmlBalancedParens (XmlBalancedParens a) = a diff --git a/src/HaskellWorks/Data/Xml/Succinct/Cursor/BlankedXml.hs b/src/HaskellWorks/Data/Xml/Succinct/Cursor/BlankedXml.hs index 7e960ba..854eaa6 100644 --- a/src/HaskellWorks/Data/Xml/Succinct/Cursor/BlankedXml.hs +++ b/src/HaskellWorks/Data/Xml/Succinct/Cursor/BlankedXml.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} module HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml ( BlankedXml(..) @@ -8,6 +9,7 @@ module HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml , lbsToBlankedXml ) where +import Control.DeepSeq import GHC.Generics import HaskellWorks.Data.Xml.Internal.Blank @@ -16,7 +18,7 @@ import qualified Data.ByteString.Lazy as LBS newtype BlankedXml = BlankedXml { unblankedXml :: [BS.ByteString] - } deriving (Eq, Show, Generic) + } deriving (Eq, Show, Generic, NFData) getBlankedXml :: BlankedXml -> [BS.ByteString] getBlankedXml (BlankedXml bs) = bs diff --git a/src/HaskellWorks/Data/Xml/Succinct/Cursor/InterestBits.hs b/src/HaskellWorks/Data/Xml/Succinct/Cursor/InterestBits.hs index 1543b9c..3932b90 100644 --- a/src/HaskellWorks/Data/Xml/Succinct/Cursor/InterestBits.hs +++ b/src/HaskellWorks/Data/Xml/Succinct/Cursor/InterestBits.hs @@ -1,7 +1,9 @@ -{-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE InstanceSigs #-} -{-# LANGUAGE MultiParamTypeClasses #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE InstanceSigs #-} +{-# LANGUAGE MultiParamTypeClasses #-} module HaskellWorks.Data.Xml.Succinct.Cursor.InterestBits ( XmlInterestBits(..) @@ -12,8 +14,10 @@ module HaskellWorks.Data.Xml.Succinct.Cursor.InterestBits ) where import Control.Applicative +import Control.DeepSeq import Data.ByteString.Internal import Data.Word +import GHC.Generics import HaskellWorks.Data.Bits.BitShown import HaskellWorks.Data.FromByteString import HaskellWorks.Data.RankSelect.Poppy512 @@ -23,7 +27,7 @@ import HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml import qualified Data.ByteString as BS import qualified Data.Vector.Storable as DVS -newtype XmlInterestBits a = XmlInterestBits a +newtype XmlInterestBits a = XmlInterestBits a deriving (Eq, Show, Generic, NFData) getXmlInterestBits :: XmlInterestBits a -> a getXmlInterestBits (XmlInterestBits a) = a