Skip to content

Commit

Permalink
Merge pull request #2 from ivan-m/master
Browse files Browse the repository at this point in the history
Added an NFData instance
  • Loading branch information
sw17ch committed Dec 9, 2011
2 parents cd829a9 + 3211338 commit 61d8999
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data-clist.cabal
Expand Up @@ -22,10 +22,12 @@ source-repository head

Library
Build-Depends: base >= 4 && < 5,
deepseq == 1.1.*,
QuickCheck >= 2.4 && < 2.5

Exposed-Modules:
Data.CircularList

ghc-options: -Wall
gHC-prof-options: -prof -auto-all
hs-source-dirs: src
7 changes: 7 additions & 0 deletions src/Data/CircularList.hs
Expand Up @@ -70,6 +70,7 @@ module Data.CircularList (
) where

import Data.List(find,unfoldr,foldl')
import Control.DeepSeq(NFData(..))
import Control.Monad(join)
import Test.QuickCheck.Arbitrary
import Test.QuickCheck.Gen
Expand Down Expand Up @@ -327,6 +328,12 @@ instance (Read a) => Read (CList a) where
instance (Eq a) => Eq (CList a) where
a == b = any (identical a) . toList $ allRotations b

instance (NFData a) => NFData (CList a) where
rnf Empty = ()
rnf (CList l f r) = rnf f
`seq` rnf l
`seq` rnf r

-- |Determine if two 'CList's are structurally identical.
identical :: (Eq a) => CList a -> CList a -> Bool
identical Empty Empty = True
Expand Down

0 comments on commit 61d8999

Please sign in to comment.