Skip to content

Commit

Permalink
Merge pull request #93 from haskell-works/add-NFData-instances
Browse files Browse the repository at this point in the history
Add NFData instances
  • Loading branch information
newhoggy committed Nov 25, 2019
2 parents 7cb0663 + edb3932 commit ab04b32
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 38 deletions.
5 changes: 3 additions & 2 deletions app/App/Commands/Count.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 0 additions & 6 deletions cabal.project.local

This file was deleted.

12 changes: 0 additions & 12 deletions hie.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion hw-xml.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -128,6 +128,7 @@ executable hw-xml
import: base, config
, attoparsec
, bytestring
, deepseq
, generic-lens
, hw-balancedparens
, hw-bits
Expand Down
5 changes: 3 additions & 2 deletions project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
;;

Expand All @@ -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 "$@"
;;

Expand Down
6 changes: 5 additions & 1 deletion src/HaskellWorks/Data/Xml/DecodeError.hs
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 5 additions & 1 deletion src/HaskellWorks/Data/Xml/Index.hs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}

module HaskellWorks.Data.Xml.Index
( 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
Expand All @@ -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
Expand Down
16 changes: 10 additions & 6 deletions src/HaskellWorks/Data/Xml/Succinct/Cursor/BalancedParens.hs
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
{-# 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(..)
, getXmlBalancedParens
) 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

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
Expand Down
6 changes: 4 additions & 2 deletions src/HaskellWorks/Data/Xml/Succinct/Cursor/BlankedXml.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module HaskellWorks.Data.Xml.Succinct.Cursor.BlankedXml
( BlankedXml(..)
Expand All @@ -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

Expand All @@ -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
Expand Down
14 changes: 9 additions & 5 deletions src/HaskellWorks/Data/Xml/Succinct/Cursor/InterestBits.hs
Original file line number Diff line number Diff line change
@@ -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(..)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ab04b32

Please sign in to comment.