Skip to content

Commit ab04b32

Browse files
authored
Merge pull request #93 from haskell-works/add-NFData-instances
Add NFData instances
2 parents 7cb0663 + edb3932 commit ab04b32

File tree

10 files changed

+41
-38
lines changed

10 files changed

+41
-38
lines changed

app/App/Commands/Count.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Control.Monad
1717
import Data.Generics.Product.Any
1818
import Data.Semigroup ((<>))
1919
import Data.Text (Text)
20+
import GHC.Generics
2021
import HaskellWorks.Data.TreeCursor
2122
import HaskellWorks.Data.Xml.DecodeResult
2223
import HaskellWorks.Data.Xml.RawDecode
@@ -40,11 +41,11 @@ import qualified System.IO as IO
4041
data Plant = Plant
4142
{ common :: String
4243
, price :: String
43-
} deriving (Eq, Show)
44+
} deriving (Eq, Show, Generic)
4445

4546
newtype Catalog = Catalog
4647
{ plants :: [Plant]
47-
} deriving (Eq, Show)
48+
} deriving (Eq, Show, Generic)
4849

4950
tags :: Value -> String -> [Value]
5051
tags xml@(XmlElement n _ _) elemName = if n == elemName

cabal.project.local

Lines changed: 0 additions & 6 deletions
This file was deleted.

hie.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

hw-xml.cabal

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ common ghc-prim { build-depends: ghc-prim >=
3838
common hedgehog { build-depends: hedgehog >= 1.0 && < 1.1 }
3939
common hspec { build-depends: hspec >= 2.5 && < 3.0 }
4040
common hw-balancedparens { build-depends: hw-balancedparens >= 0.3.0.1 && < 0.4 }
41-
common hw-bits { build-depends: hw-bits >= 0.7.0.7 && < 0.8 }
41+
common hw-bits { build-depends: hw-bits >= 0.7.0.9 && < 0.8 }
4242
common hw-hspec-hedgehog { build-depends: hw-hspec-hedgehog >= 0.1 && < 0.2 }
4343
common hw-parser { build-depends: hw-parser >= 0.1.0.1 && < 0.2 }
4444
common hw-prim { build-depends: hw-prim >= 0.6.2.39 && < 0.7 }
@@ -128,6 +128,7 @@ executable hw-xml
128128
import: base, config
129129
, attoparsec
130130
, bytestring
131+
, deepseq
131132
, generic-lens
132133
, hw-balancedparens
133134
, hw-bits

project.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ case "$cmd" in
1717

1818
build)
1919
cabal new-build all -j8 \
20-
--enable-tests --enable-benchmarks \
20+
--enable-tests --enable-benchmarks --write-ghc-environment-files=always \
2121
$CABAL_FLAGS "$@"
2222
;;
2323

@@ -26,7 +26,8 @@ case "$cmd" in
2626
;;
2727

2828
test)
29-
cabal new-test -j8 --enable-tests --disable-documentation --test-show-details=direct \
29+
cabal v2-test -j8 --enable-tests --enable-benchmarks \
30+
--write-ghc-environment-files=always --test-show-details=direct \
3031
$CABAL_FLAGS "$@"
3132
;;
3233

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
{-# LANGUAGE DeriveGeneric #-}
12
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
23

34
module HaskellWorks.Data.Xml.DecodeError where
45

5-
newtype DecodeError = DecodeError String deriving (Eq, Show)
6+
import Control.DeepSeq
7+
import GHC.Generics
8+
9+
newtype DecodeError = DecodeError String deriving (Eq, Show, Generic, NFData)

src/HaskellWorks/Data/Xml/Index.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
{-# LANGUAGE DeriveAnyClass #-}
2+
{-# LANGUAGE DeriveGeneric #-}
13
{-# LANGUAGE FlexibleInstances #-}
24

35
module HaskellWorks.Data.Xml.Index
46
( Index(..)
57
, indexVersion
68
) where
79

10+
import Control.DeepSeq
811
import Data.Serialize
912
import Data.Word
13+
import GHC.Generics
1014
import HaskellWorks.Data.Bits.BitShown
1115

1216
import qualified Data.Vector.Storable as DVS
@@ -18,7 +22,7 @@ data Index = Index
1822
{ xiVersion :: String
1923
, xiInterests :: BitShown (DVS.Vector Word64)
2024
, xiBalancedParens :: BitShown (DVS.Vector Word64)
21-
} deriving (Eq, Show)
25+
} deriving (Eq, Show, Generic, NFData)
2226

2327
putBitShownVector :: Putter (BitShown (DVS.Vector Word64))
2428
putBitShownVector = putVector . bitShown

src/HaskellWorks/Data/Xml/Succinct/Cursor/BalancedParens.hs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
{-# LANGUAGE FlexibleContexts #-}
2-
{-# LANGUAGE FlexibleInstances #-}
3-
{-# LANGUAGE InstanceSigs #-}
4-
{-# LANGUAGE MultiParamTypeClasses #-}
1+
{-# LANGUAGE DeriveGeneric #-}
2+
{-# LANGUAGE FlexibleContexts #-}
3+
{-# LANGUAGE FlexibleInstances #-}
4+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+
{-# LANGUAGE InstanceSigs #-}
6+
{-# LANGUAGE MultiParamTypeClasses #-}
57

68
module HaskellWorks.Data.Xml.Succinct.Cursor.BalancedParens
79
( XmlBalancedParens(..)
810
, getXmlBalancedParens
911
) where
1012

1113
import Control.Applicative
14+
import Control.DeepSeq
1215
import Data.Word
13-
import HaskellWorks.Data.BalancedParens as BP
16+
import GHC.Generics
17+
import HaskellWorks.Data.BalancedParens
1418
import HaskellWorks.Data.Xml.Internal.BalancedParens
1519
import HaskellWorks.Data.Xml.Internal.List
1620
import HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml
1721

1822
import qualified Data.ByteString as BS
1923
import qualified Data.Vector.Storable as DVS
2024

21-
newtype XmlBalancedParens a = XmlBalancedParens a
25+
newtype XmlBalancedParens a = XmlBalancedParens a deriving (Eq, Show, Generic, NFData)
2226

2327
getXmlBalancedParens :: XmlBalancedParens a -> a
2428
getXmlBalancedParens (XmlBalancedParens a) = a

src/HaskellWorks/Data/Xml/Succinct/Cursor/BlankedXml.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
{-# LANGUAGE DeriveGeneric #-}
1+
{-# LANGUAGE DeriveGeneric #-}
2+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
23

34
module HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml
45
( BlankedXml(..)
@@ -8,6 +9,7 @@ module HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml
89
, lbsToBlankedXml
910
) where
1011

12+
import Control.DeepSeq
1113
import GHC.Generics
1214
import HaskellWorks.Data.Xml.Internal.Blank
1315

@@ -16,7 +18,7 @@ import qualified Data.ByteString.Lazy as LBS
1618

1719
newtype BlankedXml = BlankedXml
1820
{ unblankedXml :: [BS.ByteString]
19-
} deriving (Eq, Show, Generic)
21+
} deriving (Eq, Show, Generic, NFData)
2022

2123
getBlankedXml :: BlankedXml -> [BS.ByteString]
2224
getBlankedXml (BlankedXml bs) = bs

src/HaskellWorks/Data/Xml/Succinct/Cursor/InterestBits.hs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
{-# LANGUAGE FlexibleContexts #-}
2-
{-# LANGUAGE FlexibleInstances #-}
3-
{-# LANGUAGE InstanceSigs #-}
4-
{-# LANGUAGE MultiParamTypeClasses #-}
1+
{-# LANGUAGE DeriveGeneric #-}
2+
{-# LANGUAGE FlexibleContexts #-}
3+
{-# LANGUAGE FlexibleInstances #-}
4+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+
{-# LANGUAGE InstanceSigs #-}
6+
{-# LANGUAGE MultiParamTypeClasses #-}
57

68
module HaskellWorks.Data.Xml.Succinct.Cursor.InterestBits
79
( XmlInterestBits(..)
@@ -12,8 +14,10 @@ module HaskellWorks.Data.Xml.Succinct.Cursor.InterestBits
1214
) where
1315

1416
import Control.Applicative
17+
import Control.DeepSeq
1518
import Data.ByteString.Internal
1619
import Data.Word
20+
import GHC.Generics
1721
import HaskellWorks.Data.Bits.BitShown
1822
import HaskellWorks.Data.FromByteString
1923
import HaskellWorks.Data.RankSelect.Poppy512
@@ -23,7 +27,7 @@ import HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml
2327
import qualified Data.ByteString as BS
2428
import qualified Data.Vector.Storable as DVS
2529

26-
newtype XmlInterestBits a = XmlInterestBits a
30+
newtype XmlInterestBits a = XmlInterestBits a deriving (Eq, Show, Generic, NFData)
2731

2832
getXmlInterestBits :: XmlInterestBits a -> a
2933
getXmlInterestBits (XmlInterestBits a) = a

0 commit comments

Comments
 (0)